Re: [patch 6/8] fuse: clean up setting i_size in write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Mon, 17 Mar 2008 20:19:14 +0100 Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
> 
> > From: Miklos Szeredi <mszeredi@xxxxxxx>
> > 
> > Extract common code for setting i_size in write functions into a
> > common helper.
> > 
> > Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
> > ---
> >  fs/fuse/file.c |   28 +++++++++++++++-------------
> >  1 file changed, 15 insertions(+), 13 deletions(-)
> > 
> > Index: linux/fs/fuse/file.c
> > ===================================================================
> > --- linux.orig/fs/fuse/file.c	2008-03-17 18:26:04.000000000 +0100
> > +++ linux/fs/fuse/file.c	2008-03-17 18:26:28.000000000 +0100
> > @@ -610,13 +610,24 @@ static int fuse_write_begin(struct file 
> >  	return 0;
> >  }
> >  
> > +static void fuse_write_update_size(struct inode *inode, loff_t pos)
> > +{
> > +	struct fuse_conn *fc = get_fuse_conn(inode);
> > +	struct fuse_inode *fi = get_fuse_inode(inode);
> > +
> > +	spin_lock(&fc->lock);
> > +	fi->attr_version = ++fc->attr_version;
> > +	if (pos > inode->i_size)
> > +		i_size_write(inode, pos);
> > +	spin_unlock(&fc->lock);
> > +}
> >
> > ...
> >
> > @@ -766,12 +772,8 @@ static ssize_t fuse_direct_io(struct fil
> >  	}
> >  	fuse_put_request(fc, req);
> >  	if (res > 0) {
> > -		if (write) {
> > -			spin_lock(&fc->lock);
> > -			if (pos > inode->i_size)
> > -				i_size_write(inode, pos);
> > -			spin_unlock(&fc->lock);
> > -		}
> > +		if (write)
> > +			fuse_write_update_size(inode, pos);
> 
> We require that i_mutex be held here, to prevent i_size_write() deadlocks. 
> Is it held?
> 

No, fuse uses the per connection spinlock to protect against
concurrent calls to i_size_write(), because in some cases holding
i_mutex would be difficult.

Fuse already got painfully bitten by the i_size_write() deadlock, so
I'm well aware of the problem :)

Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux