Re: [patch 3/6] [PATCH] fs: convert simple fs to new truncate

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

 



On Thu, May 27, 2010 at 12:59:29PM +0100, Al Viro wrote:
> On Thu, May 27, 2010 at 01:05:35AM +1000, npiggin@xxxxxxx wrote:
> > ===================================================================
> > --- linux-2.6.orig/fs/configfs/inode.c
> > +++ linux-2.6/fs/configfs/inode.c
> > @@ -78,9 +78,13 @@ int configfs_setattr(struct dentry * den
> >  	if (error)
> >  		return error;
> >  
> > -	error = inode_setattr(inode, iattr);
> > -	if (error)
> > -		return error;
> > +	if (iattr->ia_valid & ATTR_SIZE) {
> > +		error = simple_setsize(inode, iattr->ia_size);
> > +		if (error)
> > +			return error;
> > +	}
> > +
> > +	generic_setattr(inode, iattr);
> >  
> >  	if (!sd_iattr) {
> >  		/* setting attributes for the first time, allocate now */
> 
> That should use simple_setattr() instead of generic_setattr(); look at the
> check just before this chunk...

Thanks, agree. I wonder if we shouldn't move the setattr part over
to after the sd_iattr is allocated? Couldn't a failure result in
inconsistent "on disk" vs inode attributes?

I'm guilty of making undocumented similar change in sysfs too, so I'll
resend this patch with that reverted as well, and send patch to change
sequence independently.

 
> > +++ linux-2.6/fs/block_dev.c
> > @@ -172,8 +172,9 @@ blkdev_direct_IO(int rw, struct kiocb *i
> >  	struct file *file = iocb->ki_filp;
> >  	struct inode *inode = file->f_mapping->host;
> >  
> > -	return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode),
> > -				iov, offset, nr_segs, blkdev_get_blocks, NULL);
> > +	return blockdev_direct_IO_no_locking_newtrunc(rw, iocb, inode,
> > +				I_BDEV(inode), iov, offset, nr_segs,
> > +				blkdev_get_blocks, NULL);
> >  }
> >  
> >  int __sync_blockdev(struct block_device *bdev, int wait)
> > @@ -309,8 +310,8 @@ static int blkdev_write_begin(struct fil
> >  			struct page **pagep, void **fsdata)
> >  {
> >  	*pagep = NULL;
> > -	return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
> > -				blkdev_get_block);
> > +	return block_write_begin_newtrunc(file, mapping, pos, len, flags,
> > +				pagep, fsdata, blkdev_get_block);
> >  }
> 
> And that should be folded back into the patch #1.

I thought this hunk should remain part of the simple fs conversions,
just to leave the add core functions versus use new functions in
different parts.

How's this?
--
From: Nick Piggin <npiggin@xxxxxxx>
Subject: [PATCH] fs: convert simple fs to new truncate

Convert simple filesystems: ramfs, configfs, sysfs, block_dev to new truncate
sequence.

Cc: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Nick Piggin <npiggin@xxxxxxx>
---
 fs/block_dev.c        |    9 +++++----
 fs/configfs/inode.c   |   10 +++++++---
 fs/ramfs/file-mmu.c   |    1 +
 fs/ramfs/file-nommu.c |    7 ++++---
 fs/sysfs/inode.c      |    6 +-----
 5 files changed, 18 insertions(+), 15 deletions(-)

Index: linux-2.6/fs/configfs/inode.c
===================================================================
--- linux-2.6.orig/fs/configfs/inode.c
+++ linux-2.6/fs/configfs/inode.c
@@ -72,16 +72,11 @@ int configfs_setattr(struct dentry * den
 	if (!sd)
 		return -EINVAL;
 
-	sd_iattr = sd->s_iattr;
-
-	error = inode_change_ok(inode, iattr);
-	if (error)
-		return error;
-
-	error = inode_setattr(inode, iattr);
+	error = simple_setattr(dentry, iattr);
 	if (error)
 		return error;
 
+	sd_iattr = sd->s_iattr;
 	if (!sd_iattr) {
 		/* setting attributes for the first time, allocate now */
 		sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
Index: linux-2.6/fs/ramfs/file-mmu.c
===================================================================
--- linux-2.6.orig/fs/ramfs/file-mmu.c
+++ linux-2.6/fs/ramfs/file-mmu.c
@@ -50,5 +50,6 @@ const struct file_operations ramfs_file_
 };
 
 const struct inode_operations ramfs_file_inode_operations = {
+	.setattr	= simple_setattr,
 	.getattr	= simple_getattr,
 };
Index: linux-2.6/fs/ramfs/file-nommu.c
===================================================================
--- linux-2.6.orig/fs/ramfs/file-nommu.c
+++ linux-2.6/fs/ramfs/file-nommu.c
@@ -146,7 +146,7 @@ static int ramfs_nommu_resize(struct ino
 			return ret;
 	}
 
-	ret = vmtruncate(inode, newsize);
+	ret = simple_setsize(inode, newsize);
 
 	return ret;
 }
@@ -169,7 +169,8 @@ static int ramfs_nommu_setattr(struct de
 
 	/* pick out size-changing events */
 	if (ia->ia_valid & ATTR_SIZE) {
-		loff_t size = i_size_read(inode);
+		loff_t size = inode->i_size;
+
 		if (ia->ia_size != size) {
 			ret = ramfs_nommu_resize(inode, ia->ia_size, size);
 			if (ret < 0 || ia->ia_valid == ATTR_SIZE)
@@ -182,7 +183,7 @@ static int ramfs_nommu_setattr(struct de
 		}
 	}
 
-	ret = inode_setattr(inode, ia);
+	generic_setattr(inode, ia);
  out:
 	ia->ia_valid = old_ia_valid;
 	return ret;
Index: linux-2.6/fs/sysfs/inode.c
===================================================================
--- linux-2.6.orig/fs/sysfs/inode.c
+++ linux-2.6/fs/sysfs/inode.c
@@ -117,13 +117,11 @@ int sysfs_setattr(struct dentry *dentry,
 	if (error)
 		goto out;
 
-	iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */
-
-	error = inode_setattr(inode, iattr);
-	if (error)
-		goto out;
+	/* this ignores size changes */
+	generic_setattr(inode, iattr);
 
 	error = sysfs_sd_setattr(sd, iattr);
+
 out:
 	mutex_unlock(&sysfs_mutex);
 	return error;
Index: linux-2.6/fs/block_dev.c
===================================================================
--- linux-2.6.orig/fs/block_dev.c
+++ linux-2.6/fs/block_dev.c
@@ -172,8 +172,9 @@ blkdev_direct_IO(int rw, struct kiocb *i
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 
-	return blockdev_direct_IO_no_locking(rw, iocb, inode, I_BDEV(inode),
-				iov, offset, nr_segs, blkdev_get_blocks, NULL);
+	return blockdev_direct_IO_no_locking_newtrunc(rw, iocb, inode,
+				I_BDEV(inode), iov, offset, nr_segs,
+				blkdev_get_blocks, NULL);
 }
 
 int __sync_blockdev(struct block_device *bdev, int wait)
@@ -309,8 +310,8 @@ static int blkdev_write_begin(struct fil
 			struct page **pagep, void **fsdata)
 {
 	*pagep = NULL;
-	return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
-				blkdev_get_block);
+	return block_write_begin_newtrunc(file, mapping, pos, len, flags,
+				pagep, fsdata, blkdev_get_block);
 }
 
 static int blkdev_write_end(struct file *file, struct address_space *mapping,
--
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