login
Header Space

 
 

Re: [patch 2/5] VFS: pass open file to ->getattr()

Previous thread: [patch 4/5] VFS: allow filesystems to implement atomic open+truncate by Miklos Szeredi on Friday, September 21, 2007 - 8:23 am. (4 messages)

Next thread: [patch 3/5] VFS: pass open file to ->xattr() by Miklos Szeredi on Friday, September 21, 2007 - 8:23 am. (12 messages)
To: <akpm@...>
Cc: <hch@...>, <linux-kernel@...>, <linux-fsdevel@...>
Date: Friday, September 21, 2007 - 8:23 am

From: Miklos Szeredi &lt;mszeredi@suse.cz&gt;

Pass the open file into the filesystem's -&gt;getattr() method for
fstat().

This is needed to be able to correctly implement open-unlink-fstat
semantics in some filesystem such as sshfs, without having to resort
to "silly-renaming".

Do this by adding a 'struct file *' parameter to i_op-&gt;getattr().  For
fstat() pass the open file pointer, in other cases pass NULL.

This is safe from a compatibility standpoint, out-of-tree old stuff
will continue to work, but will get a warning at compile time.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
---

Index: linux/fs/9p/vfs_inode.c
===================================================================
--- linux.orig/fs/9p/vfs_inode.c	2007-09-21 14:08:25.000000000 +0200
+++ linux/fs/9p/vfs_inode.c	2007-09-21 14:08:40.000000000 +0200
@@ -706,7 +706,7 @@ done:
 
 static int
 v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
-		 struct kstat *stat)
+		 struct kstat *stat, struct file *file)
 {
 	int err;
 	struct v9fs_session_info *v9ses;
@@ -717,7 +717,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, s
 	err = -EPERM;
 	v9ses = v9fs_inode2v9ses(dentry-&gt;d_inode);
 	if (v9ses-&gt;cache == CACHE_LOOSE)
-		return simple_getattr(mnt, dentry, stat);
+		return simple_getattr(mnt, dentry, stat, file);
 
 	fid = v9fs_fid_lookup(dentry);
 	if (IS_ERR(fid))
Index: linux/fs/afs/inode.c
===================================================================
--- linux.orig/fs/afs/inode.c	2007-09-21 14:08:25.000000000 +0200
+++ linux/fs/afs/inode.c	2007-09-21 14:08:40.000000000 +0200
@@ -295,7 +295,7 @@ error_unlock:
  * read the attributes of an inode
  */
 int afs_getattr(struct vfsmount *mnt, struct dentry *dentry,
-		      struct kstat *stat)
+		      struct kstat *stat, struct file *file)
 {
 	struct inode *inode;
 
Index: linux/fs/afs/internal.h
===================================================================
--- linux.orig/fs/afs/internal.h	2007-09-21 14:08:25.0...
To: Miklos Szeredi <miklos@...>
Cc: <akpm@...>, <hch@...>, <linux-kernel@...>, <linux-fsdevel@...>
Date: Friday, September 21, 2007 - 2:37 pm

It's not much of an inode operation anymore if you need to pass a file
to it...  Since the attributes are really part of the inode and not
the file, this seems like a bit of a hack.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

-
To: <adilger@...>
Cc: <miklos@...>, <akpm@...>, <hch@...>, <linux-kernel@...>, <linux-fsdevel@...>
Date: Friday, September 21, 2007 - 5:07 pm

Well, the data is part of the inode and not the file as well.  So why
are read/write special?

OK, I realize now, that with special files (device, fifo) the I/O is
actually on the open file and _not_ on the inode.  So the above is
only true for regular files.

And so it really would make sense to make a separate fgetattr() file
operation, so we only get it for regular files and not for special
files.  Because for the specail file case it really doesn't make sense
to pass the file pointer to the filesystem, since the filesystem knows
nothing about the open file.

Miklos
-
Previous thread: [patch 4/5] VFS: allow filesystems to implement atomic open+truncate by Miklos Szeredi on Friday, September 21, 2007 - 8:23 am. (4 messages)

Next thread: [patch 3/5] VFS: pass open file to ->xattr() by Miklos Szeredi on Friday, September 21, 2007 - 8:23 am. (12 messages)
speck-geostationary