[PATCH] uverbs: kill last remaining modular get_empty_filp user

2008-02-25 Thread Christoph Hellwig
uvers should be using the proper alloc_file helper instead of an
open-coded get_empty_filp.  In fact this was the last modular user
so we can kill the export aswell and force people to use the proper
interface.

Also remove the useless setting of .owner and the fops_get because all
this is not required for file_operations instances in the same module
as the underlying filesystem.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/drivers/infiniband/core/uverbs_main.c
===
--- linux-2.6.orig/drivers/infiniband/core/uverbs_main.c2008-02-25 
20:05:12.0 +0100
+++ linux-2.6/drivers/infiniband/core/uverbs_main.c 2008-02-25 
20:05:46.0 +0100
@@ -372,7 +372,6 @@ static int ib_uverbs_event_close(struct 
 }
 
 static const struct file_operations uverbs_event_fops = {
-   .owner   = THIS_MODULE,
.read= ib_uverbs_event_read,
.poll= ib_uverbs_event_poll,
.release = ib_uverbs_event_close,
@@ -516,26 +515,21 @@ struct file *ib_uverbs_alloc_event_file(
goto err;
}
 
-   filp = get_empty_filp();
+   /*
+* fops_get() can't fail here, because we're coming from a
+* system call on a uverbs file, which will already have a
+* module reference.
+*/
+   filp = alloc_file(uverbs_event_mnt, uverbs_event_mnt-mnt_root,
+ FMODE_READ, uverbs_event_fops);
if (!filp) {
ret = -ENFILE;
goto err_fd;
}
 
+   filp-private_data = ev_file;
ev_file-file  = filp;
 
-   /*
-* fops_get() can't fail here, because we're coming from a
-* system call on a uverbs file, which will already have a
-* module reference.
-*/
-   filp-f_op = fops_get(uverbs_event_fops);
-   filp-f_path.mnt   = mntget(uverbs_event_mnt);
-   filp-f_path.dentry= dget(uverbs_event_mnt-mnt_root);
-   filp-f_mapping= filp-f_path.dentry-d_inode-i_mapping;
-   filp-f_flags  = O_RDONLY;
-   filp-f_mode   = FMODE_READ;
-   filp-private_data = ev_file;
 
return filp;
 
Index: linux-2.6/fs/file_table.c
===
--- linux-2.6.orig/fs/file_table.c  2008-02-25 20:05:12.0 +0100
+++ linux-2.6/fs/file_table.c   2008-02-25 20:05:46.0 +0100
@@ -80,9 +80,13 @@ int proc_nr_files(ctl_table *table, int 
 }
 #endif
 
-/* Find an unused file structure and return a pointer to it.
+/*
+ * Find an unused file structure and return a pointer to it.
  * Returns NULL, if there are no more free file structures or
  * we run out of memory.
+ *
+ * Note that this is an internal helper.  Please use alloc_file
+ * or anon_inode_getfd instead.
  */
 struct file *get_empty_filp(void)
 {
@@ -135,8 +139,6 @@ fail:
return NULL;
 }
 
-EXPORT_SYMBOL(get_empty_filp);
-
 /**
  * alloc_file - allocate and initialize a 'struct file'
  * @mnt: the vfsmount on which the file will reside
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Block devices

2008-02-21 Thread Christoph Hellwig
On Thu, Feb 21, 2008 at 02:05:52AM -0500, David H. Lynch Jr. wrote:
 Can I boot an initramfs kernel without a block device ?

Yes.

 Can I write a filesystem driver for a flash device that does not
 require a block device ?

Yes.

 Are their any examples of something even close ?

For that particular flash case there's just jffs2 in the kernel tree,
with some more flash filesystems under development.  You can of
course have network and in-memory filesystems aswell.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: NFS/LSM: allow NFS to control all of its own mount options

2008-02-19 Thread Christoph Hellwig
Please don't introduce a special case for just nfs.  All filesystems
should control their mount options, so please provide some library
helpers for context= handling and move it into all filesystems that
can support selinux.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [2.6 patch] make vfs_ioctl() static

2008-02-17 Thread Christoph Hellwig
On Sun, Feb 17, 2008 at 10:18:42AM +0200, Adrian Bunk wrote:
 This patch makes the needlessly global vfs_ioctl() static.

I think the point was toa eventually export it for stackable filesystem
use.  But until they start using it marking it static seems fine with
me.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re[2]: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points

2008-02-16 Thread Christoph Hellwig
On Sat, Feb 16, 2008 at 11:51:52AM +0300, Q wrote:
 At first glance cifs_get_inode_info_remote won't work cause it's old dfs
 code not new one. But I caught what Christoph meant now, and will try to
 rewrite it this way.

Yes, this was supposed to be a refactoring of the existing code.  By
doing your patch ontop of it you just have to replace the
cifs_get_inode_info_remote with the correct content :)

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] ext3 freeze feature

2008-02-16 Thread Christoph Hellwig
On Fri, Feb 15, 2008 at 08:51:15PM +0900, Takashi Sato wrote:
 So XFS_IOC_FREEZE and XFS_IOC_THAW cannot be lifted to generic code simply.
 I think we should create new generic numbers for freeze and thaw

Actually we've lifted specific ioctls to the generic layer before all
the time in drivers.  That's the only way to make functionality that was
specific to a single driver (or in this case filesystem) generic.  If
the numbering issues confuses you make sure to add a big comment
describing it

 And xfs_freeze calls XFS_IOC_FREEZE with a magic number 1, but what is 1?

As Eric said it's ignored.

 Instead, I'd like the sec to timeout on freeze API in order to thaw
 the filesystem automatically.  It can prevent a filesystem from staying
 frozen forever.
 (Because a freezer may cause a deadlock by accessing the frozen filesystem.)

Timeout based locking is generally a horrible idea, there's a reason
we don't have any primitives for that in the kernel :)
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 00/10] mount ownership and unprivileged mount syscall (v8)

2008-02-15 Thread Christoph Hellwig
On Thu, Feb 14, 2008 at 10:21:03PM -0800, Andrew Morton wrote:
 Linus has just merged all the VFS renaming patches, so the decks
 are clear for looking at this work.
 
 However David and Christoph are beavering away on the r-o-bind-mounts
 patches and I expect that there will be overlaps with unprivileged mounts.
 
 Could we coordinate things a bit please?  Decide who goes first, review
 and maybe even test each others work, etc?

Al is setting up a git tree for VFS work.  per-mount r/o will go in
as one of the first things, aswell as his rework of the path lookup
logic to fix the intents mess.

 
 Thanks.
---end quoted text---
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 00/10] mount ownership and unprivileged mount syscall (v8)

2008-02-15 Thread Christoph Hellwig
On Fri, Feb 15, 2008 at 01:09:51AM -0800, Andrew Morton wrote:
   However David and Christoph are beavering away on the r-o-bind-mounts
   patches and I expect that there will be overlaps with unprivileged mounts.
   
   Could we coordinate things a bit please?  Decide who goes first, review
   and maybe even test each others work, etc?
  
  Al is setting up a git tree for VFS work.  per-mount r/o will go in
  as one of the first things, aswell as his rework of the path lookup
  logic to fix the intents mess.
  
 
 That didn't answer my question..

Well, Al as the defacto VFS maintainer will decide on the ordering.
Reviewing this stuff properly is still on my todo list, but currently
I'm busy with more important things.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points

2008-02-15 Thread Christoph Hellwig
On Fri, Feb 15, 2008 at 07:37:35PM +0300, Q (Igor Mammedov) wrote:
 Sorry guys, but I have a lot of work for the last 3 weeks,
 so I couldn't spare much time for a hobby and react quickly.

No problem.  I know this problem very well as almost all of my core
kernel contributions are spare time as well.  Thanks for keeping
up the work.

 Here is what I've done the last weekend.
 Attached:
  fixed patch [5/5] 
 (0001-DFS-patch-that-connects-inode-with-dfs-handling-ops.patch).
  fixed mixed case in struct member 
 (0002-Fixed-mixed-case-name-in-structure-dfs_info3_param.patch)

The second one is trivially correct and should be pushed to Linus asap
as small cleanup.  Patch 1 is not exactly what I had in mind, I was
thinking about factoring out the common bits of cifs-cifs_get_inode_info
and cifs-cifs_get_inode_info_unix to avoid having all the logic to
set the various options twice.  I've attached two quick and untested
patches showing what I mean.  I think in this case having the ifdef
for that two line statement setting the inode operations here is fine.
But thinking about it I'm not even sure if it's good idea to make
dfs support conditional.  Any reason it can't just be included
unconditionally?


Index: linux-2.6/fs/cifs/inode.c
===
--- linux-2.6.orig/fs/cifs/inode.c  2008-02-15 17:44:48.0 +0100
+++ linux-2.6/fs/cifs/inode.c   2008-02-15 17:52:04.0 +0100
@@ -29,6 +29,46 @@
 #include cifs_debug.h
 #include cifs_fs_sb.h
 
+
+static void cifs_set_ops(struct inode *inode)
+{
+   struct cifs_sb_info *cifs_sb = CIFS_SB(inode-i_sb);
+
+   switch (inode-i_mode  S_IFMT) {
+   case S_IFREG:
+   inode-i_op = cifs_file_inode_ops;
+   if (cifs_sb-mnt_cifs_flags  CIFS_MOUNT_DIRECT_IO) {
+   if (cifs_sb-mnt_cifs_flags  CIFS_MOUNT_NO_BRL)
+   inode-i_fop = cifs_file_direct_nobrl_ops;
+   else
+   inode-i_fop = cifs_file_direct_ops;
+   } else if (cifs_sb-mnt_cifs_flags  CIFS_MOUNT_NO_BRL)
+   inode-i_fop = cifs_file_nobrl_ops;
+   else { /* not direct, send byte range locks */
+   inode-i_fop = cifs_file_ops;
+   }
+
+
+   /* check if server can support readpages */
+   if (cifs_sb-tcon-ses-server-maxBuf 
+   PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
+   inode-i_data.a_ops = cifs_addr_ops_smallbuf;
+   else
+   inode-i_data.a_ops = cifs_addr_ops;
+   break;
+   case S_IFDIR:
+   inode-i_op = cifs_dir_inode_ops;
+   inode-i_fop = cifs_dir_ops;
+   break;
+   case S_IFLNK:
+   inode-i_op = cifs_symlink_inode_ops;
+   break;
+   default:
+   init_special_inode(inode, inode-i_mode, inode-i_rdev);
+   break;
+   }
+}
+
 int cifs_get_inode_info_unix(struct inode **pinode,
const unsigned char *search_path, struct super_block *sb, int xid)
 {
@@ -178,39 +218,8 @@ int cifs_get_inode_info_unix(struct inod
cFYI(1, (Size %ld and blocks %llu,
(unsigned long) inode-i_size,
(unsigned long long)inode-i_blocks));
-   if (S_ISREG(inode-i_mode)) {
-   cFYI(1, (File inode));
-   inode-i_op = cifs_file_inode_ops;
-   if (cifs_sb-mnt_cifs_flags  CIFS_MOUNT_DIRECT_IO) {
-   if (cifs_sb-mnt_cifs_flags  CIFS_MOUNT_NO_BRL)
-   inode-i_fop =
-   cifs_file_direct_nobrl_ops;
-   else
-   inode-i_fop = cifs_file_direct_ops;
-   } else if (cifs_sb-mnt_cifs_flags  CIFS_MOUNT_NO_BRL)
-   inode-i_fop = cifs_file_nobrl_ops;
-   else /* not direct, send byte range locks */
-   inode-i_fop = cifs_file_ops;
-
-   /* check if server can support readpages */
-   if (pTcon-ses-server-maxBuf 
-   PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
-   inode-i_data.a_ops = cifs_addr_ops_smallbuf;
-   else
-   inode-i_data.a_ops = cifs_addr_ops;
-   } else if (S_ISDIR(inode-i_mode)) {
-   cFYI(1, (Directory inode));
-   inode-i_op = cifs_dir_inode_ops;
-   inode-i_fop = cifs_dir_ops;
-   } else if (S_ISLNK(inode-i_mode)) {
-   cFYI(1, (Symbolic Link inode));
-   inode-i_op = cifs_symlink_inode_ops;
-   /* 

Re: [linux-cifs-client] review 5, was Re: projected date for mount.cifs to support DFS junction points

2008-02-15 Thread Christoph Hellwig
If you like these kind of consolidation patches here's another one:


Index: linux-2.6/fs/cifs/inode.c
===
--- linux-2.6.orig/fs/cifs/inode.c  2008-02-15 22:46:08.0 +0100
+++ linux-2.6/fs/cifs/inode.c   2008-02-15 23:09:28.0 +0100
@@ -98,6 +98,90 @@ static int cifs_get_inode_info_remote(st
return rc;
 }
 
+static void cifs_unix_info_to_inode(struct inode *inode,
+   FILE_UNIX_BASIC_INFO *info, int force_uid_gid)
+{
+   struct cifs_sb_info *cifs_sb = CIFS_SB(inode-i_sb);
+   struct cifsInodeInfo *cifsInfo = CIFS_I(inode);
+   __u64 num_of_bytes = le64_to_cpu(info-NumOfBytes);
+   __u64 end_of_file = le64_to_cpu(info-EndOfFile);
+
+   inode-i_atime = cifs_NTtimeToUnix(le64_to_cpu(info-LastAccessTime));
+   inode-i_mtime =
+   cifs_NTtimeToUnix(le64_to_cpu(info-LastModificationTime));
+   inode-i_ctime = cifs_NTtimeToUnix(le64_to_cpu(info-LastStatusChange));
+   inode-i_mode = le64_to_cpu(info-Permissions);
+
+   /*
+* Since we set the inode type below we need to mask off
+* to avoid strange results if bits set above.
+*/
+   inode-i_mode = ~S_IFMT;
+   switch (le32_to_cpu(info-Type)) {
+   case UNIX_FILE:
+   inode-i_mode |= S_IFREG;
+   break;
+   case UNIX_SYMLINK:
+   inode-i_mode |= S_IFLNK;
+   break;
+   case UNIX_DIR:
+   inode-i_mode |= S_IFDIR;
+   break;
+   case UNIX_CHARDEV:
+   inode-i_mode |= S_IFCHR;
+   inode-i_rdev = MKDEV(le64_to_cpu(info-DevMajor),
+ le64_to_cpu(info-DevMinor)  MINORMASK);
+   break;
+   case UNIX_BLOCKDEV:
+   inode-i_mode |= S_IFBLK;
+   inode-i_rdev = MKDEV(le64_to_cpu(info-DevMajor),
+ le64_to_cpu(info-DevMinor)  MINORMASK);
+   break;
+   case UNIX_FIFO:
+   inode-i_mode |= S_IFIFO;
+   break;
+   case UNIX_SOCKET:
+   inode-i_mode |= S_IFSOCK;
+   break;
+   default:
+   /* safest to call it a file if we do not know */
+   inode-i_mode |= S_IFREG;
+   cFYI(1, (unknown type %d, le32_to_cpu(info-Type)));
+   break;
+   }
+
+   if ((cifs_sb-mnt_cifs_flags  CIFS_MOUNT_OVERR_UID) 
+   !force_uid_gid)
+   inode-i_uid = cifs_sb-mnt_uid;
+   else
+   inode-i_uid = le64_to_cpu(info-Uid);
+
+   if ((cifs_sb-mnt_cifs_flags  CIFS_MOUNT_OVERR_GID) 
+   !force_uid_gid)
+   inode-i_gid = cifs_sb-mnt_gid;
+   else
+   inode-i_gid = le64_to_cpu(info-Gid);
+
+   inode-i_nlink = le64_to_cpu(info-Nlinks);
+
+   spin_lock(inode-i_lock);
+   if (is_size_safe_to_change(cifsInfo, end_of_file)) {
+   /*
+* We can not safely change the file size here if the client
+* is writing to it due to potential races.
+*/
+   i_size_write(inode, end_of_file);
+
+   /*
+* i_blocks is not related to (i_size / i_blksize),
+* but instead 512 byte (2**9) size is required for
+* calculating num blocks.
+*/
+   inode-i_blocks = (512 - 1 + num_of_bytes)  9;
+   }
+   spin_unlock(inode-i_lock);
+}
+
 int cifs_get_inode_info_unix(struct inode **pinode,
const unsigned char *search_path, struct super_block *sb, int xid)
 {
@@ -122,7 +206,6 @@ int cifs_get_inode_info_unix(struct inod
return rc;
else {
struct cifsInodeInfo *cifsInfo;
-   __u32 type = le32_to_cpu(findData.Type);
__u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes);
__u64 end_of_file = le64_to_cpu(findData.EndOfFile);
 
@@ -153,73 +236,8 @@ int cifs_get_inode_info_unix(struct inod
/* this is ok to set on every inode revalidate */
atomic_set(cifsInfo-inUse, 1);
 
-   inode-i_atime =
-   cifs_NTtimeToUnix(le64_to_cpu(findData.LastAccessTime));
-   inode-i_mtime =
-   cifs_NTtimeToUnix(le64_to_cpu
-   (findData.LastModificationTime));
-   inode-i_ctime =
-   cifs_NTtimeToUnix(le64_to_cpu(findData.LastStatusChange));
-   inode-i_mode = le64_to_cpu(findData.Permissions);
-   /* since we set the inode type below we need to mask off
-  to avoid strange results if bits set above */
-   inode-i_mode = ~S_IFMT;
-   if (type == UNIX_FILE) {
-   inode-i_mode |= S_IFREG;
-   } else if (type == UNIX_SYMLINK) {
-   inode-i_mode |= S_IFLNK;
-   

Re: i_version changes

2008-02-13 Thread Christoph Hellwig
On Tue, Feb 12, 2008 at 03:06:25PM -0500, J. Bruce Fields wrote:
  First there's a complete lack of documentation on this, which is very
  bad.  Please document what the new semantics for i_version on regular
  files are supposed to be, and how it differes from the existing
  semantics for directories.
  
  Second abusing one of the rather scare superblock mount flags is
  a bad idea.  It would be much better to set this through -setattr
  and an extension of struct iattr.  Especially as we need to convert
  file_update_time to update c and mtime through -setattr anyway.
 
 I don't understand that comment.  (What is this in the second
 sentence, for example?)

i_version.  Instead of hardcoding i_version updates in file_update_time
it would be better to add an ia_verstion to struct iattr and update it
that way.

  Third using the MS_ flag but then actually having a filesystem
  mount option to enable it is more than confusing.  After all MS_
  options (at least the exported parts) are the mount ABI for common
  options.  Also this option doesn't show up in -show_options,
  which is something Miklos will beat you up for :)
  I'm also not convinced this should be option behaviour, either you
  do update i_version for a given filesystem or you don't - having
  an obscure mount option will only give you confusion.
 
 That does sound likely to be confusing.  Any chance we could just make
 the new behavior mandatory?
 
 The one thing we need in nfsd is just an easy (in-kernel) way to check
 whether a given filesystem supports this, so nfsd can decide whether to
 use ctime or i_version as the change attribute.

Probably through export_operations somehow.  Andreas mentioned in the
other reply that he wants it only conditionally due to the overhead
on extN, and enabling this from an export operation called when nfs
exporting a filesystem.

Btw, stupid question:  the commit message for the i_version changes
mentions this is to work around lack of granularity for ctime updates.
But all modern filesystems (and I includ ext4 in that here) have 64bit
timestamps already, so that should be enough.  It would certainly
avoid all this additional code, and especially the additional space
used in struct inode which can hurt quite a lot.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: BTRFS partition usage...

2008-02-12 Thread Christoph Hellwig
On Tue, Feb 12, 2008 at 03:35:57PM -0800, David Miller wrote:
 What XFS does is really unfortunate, let's learn from it's
 mistake.

I'd rather say what Sun did with their disklabels was rather unfortunate :)
But yeah, new filesystem should cater for it's braindamage because it
doesn't have any kind of runtime cost at all.   XFS was designed for
IRIX back then which had disklabels just like the SUN ones, just without
the braindamage of having the disklabel inside the partition..

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: remove some of cifs hard to read ifdefs

2008-02-12 Thread Christoph Hellwig
On Tue, Feb 12, 2008 at 03:25:49PM -0600, Steve French wrote:
 On Feb 7, 2008 12:25 PM, Christoph Hellwig [EMAIL PROTECTED] wrote:
  and while I'm at it a lot of the non-DFS additions to cifs aren't quite
  up to standards for kernel code either, lots of useless braces, wierd
  coding style and ifdef mania.
 The useless braces should be removed now.  The ifdef mania should be
 cut by about a quarter by the following patch (following up on the
 patch idea posted late last week):
 
 http://git.kernel.org/?p=linux/kernel/git/sfrench/cifs-2.6.git;a=commitdiff;h=90c81e0b0eda214196cbe4340facbce8cc797ee7

Thanks, this starts to look a lot better.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] efs: move headers out of include/linux/

2008-02-09 Thread Christoph Hellwig
Merge include/linux/efs_fs{_i,_dir}.h into fs/efs/efs.h.  efs_vh.h
remains there because this is the IRIX volume header and shouldn't
really be handled by efs but by the partitioning code.  efs_sb.h
remains there for now because it's exported to userspace.  Of course
this wrong and aboot should have a copy of it's own, but I'll leave
that to a separate patch to avoid any contention.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/efs/dir.c
===
--- linux-2.6.orig/fs/efs/dir.c 2008-02-09 10:11:47.0 +0100
+++ linux-2.6/fs/efs/dir.c  2008-02-09 10:12:33.0 +0100
@@ -5,8 +5,8 @@
  */
 
 #include linux/buffer_head.h
-#include linux/efs_fs.h
 #include linux/smp_lock.h
+#include efs.h
 
 static int efs_readdir(struct file *, void *, filldir_t);
 
Index: linux-2.6/fs/efs/efs.h
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6/fs/efs/efs.h  2008-02-09 10:16:16.0 +0100
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 1999 Al Smith
+ *
+ * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
+ * Portions derived from IRIX header files (c) 1988 Silicon Graphics
+ */
+#ifndef _EFS_EFS_H_
+#define _EFS_EFS_H_
+
+#include linux/fs.h
+#include asm/uaccess.h
+
+#define EFS_VERSION 1.0a
+
+static const char cprt[] = EFS: EFS_VERSION - (c) 1999 Al Smith [EMAIL 
PROTECTED];
+
+
+/* 1 block is 512 bytes */
+#defineEFS_BLOCKSIZE_BITS  9
+#defineEFS_BLOCKSIZE   (1  EFS_BLOCKSIZE_BITS)
+
+typedefint32_t efs_block_t;
+typedef uint32_t   efs_ino_t;
+
+#defineEFS_DIRECTEXTENTS   12
+
+/*
+ * layout of an extent, in memory and on disk. 8 bytes exactly.
+ */
+typedef union extent_u {
+   unsigned char raw[8];
+   struct extent_s {
+   unsigned intex_magic:8; /* magic # (zero) */
+   unsigned intex_bn:24;   /* basic block */
+   unsigned intex_length:8;/* numblocks in this extent */
+   unsigned intex_offset:24;   /* logical offset into file */
+   } cooked;
+} efs_extent;
+
+typedef struct edevs {
+   __be16  odev;
+   __be32  ndev;
+} efs_devs;
+
+/*
+ * extent based filesystem inode as it appears on disk.  The efs inode
+ * is exactly 128 bytes long.
+ */
+struct efs_dinode {
+   __be16  di_mode;/* mode and type of file */
+   __be16  di_nlink;   /* number of links to file */
+   __be16  di_uid; /* owner's user id */
+   __be16  di_gid; /* owner's group id */
+   __be32  di_size;/* number of bytes in file */
+   __be32  di_atime;   /* time last accessed */
+   __be32  di_mtime;   /* time last modified */
+   __be32  di_ctime;   /* time created */
+   __be32  di_gen; /* generation number */
+   __be16  di_numextents;  /* # of extents */
+   u_char  di_version; /* version of inode */
+   u_char  di_spare;   /* spare - used by AFS */
+   union di_addr {
+   efs_extent  di_extents[EFS_DIRECTEXTENTS];
+   efs_devsdi_dev; /* device for IFCHR/IFBLK */
+   } di_u;
+};
+
+/* efs inode storage in memory */
+struct efs_inode_info {
+   int numextents;
+   int lastextent;
+
+   efs_extent  extents[EFS_DIRECTEXTENTS];
+   struct inodevfs_inode;
+};
+
+#include linux/efs_fs_sb.h
+
+#define EFS_DIRBSIZE_BITS  EFS_BLOCKSIZE_BITS
+#define EFS_DIRBSIZE   (1  EFS_DIRBSIZE_BITS)
+
+struct efs_dentry {
+   __be32  inode;
+   unsigned char   namelen;
+   charname[3];
+};
+
+#define EFS_DENTSIZE   (sizeof(struct efs_dentry) - 3 + 1)
+#define EFS_MAXNAMELEN  ((1  (sizeof(char) * 8)) - 1)
+
+#define EFS_DIRBLK_HEADERSIZE  4
+#define EFS_DIRBLK_MAGIC   0xbeef  /* moo */
+
+struct efs_dir {
+   __be16  magic;
+   unsigned char   firstused;
+   unsigned char   slots;
+
+   unsigned char   space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE];
+};
+
+#define EFS_MAXENTS \
+   ((EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE) / \
+(EFS_DENTSIZE + sizeof(char)))
+
+#define EFS_SLOTAT(dir, slot) EFS_REALOFF((dir)-space[slot])
+
+#define EFS_REALOFF(offset) ((offset  1))
+
+
+static inline struct efs_inode_info *INODE_INFO(struct inode *inode)
+{
+   return container_of(inode, struct efs_inode_info, vfs_inode);
+}
+
+static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb)
+{
+   return sb-s_fs_info;
+}
+
+struct statfs;
+struct fid;
+
+extern const struct inode_operations efs_dir_inode_operations;
+extern const struct file_operations efs_dir_operations;
+extern const struct address_space_operations efs_symlink_aops

Re: [RFC] ext3 freeze feature

2008-02-08 Thread Christoph Hellwig
On Fri, Feb 08, 2008 at 08:26:57AM -0500, Andreas Dilger wrote:
 You may as well make the common ioctl the same as the XFS version,
 both by number and parameters, so that applications which already
 understand the XFS ioctl will work on other filesystems.

Yes.  In facy you should be able to lift the implementations of
XFS_IOC_FREEZE and XFS_IOC_THAW to generic code, there's nothing
XFS-specific in there.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] udf: kill udf_set_blocksize

2008-02-08 Thread Christoph Hellwig
This helper has been quite useless since sb_min_blocksize was introduced
and is misnamed while we're at it.  Just opencode the few lines in the
caller instead.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/udf/super.c
===
--- linux-2.6.orig/fs/udf/super.c   2008-02-09 07:48:41.0 +0100
+++ linux-2.6/fs/udf/super.c2008-02-09 07:56:18.0 +0100
@@ -587,44 +587,6 @@ static int udf_remount_fs(struct super_b
return 0;
 }
 
-/*
- * udf_set_blocksize
- *
- * PURPOSE
- * Set the block size to be used in all transfers.
- *
- * DESCRIPTION
- * To allow room for a DMA transfer, it is best to guess big when unsure.
- * This routine picks 2048 bytes as the blocksize when guessing. This
- * should be adequate until devices with larger block sizes become common.
- *
- * Note that the Linux kernel can currently only deal with blocksizes of
- * 512, 1024, 2048, 4096, and 8192 bytes.
- *
- * PRE-CONDITIONS
- * sb  Pointer to _locked_ superblock.
- *
- * POST-CONDITIONS
- * sb-s_blocksize Blocksize.
- * sb-s_blocksize_bitslog2 of blocksize.
- * return0   Blocksize is valid.
- * return1   Blocksize is invalid.
- *
- * HISTORY
- * July 1, 1997 - Andrew E. Mileski
- * Written, tested, and released.
- */
-static int udf_set_blocksize(struct super_block *sb, int bsize)
-{
-   if (!sb_min_blocksize(sb, bsize)) {
-   udf_debug(Bad block size (%d)\n, bsize);
-   printk(KERN_ERR udf: bad block size (%d)\n, bsize);
-   return 0;
-   }
-
-   return sb-s_blocksize;
-}
-
 static int udf_vrs(struct super_block *sb, int silent)
 {
struct volStructDesc *vsd = NULL;
@@ -1776,8 +1738,11 @@ static int udf_fill_super(struct super_b
sbi-s_nls_map = uopt.nls_map;
 
/* Set the block size for all transfers */
-   if (!udf_set_blocksize(sb, uopt.blocksize))
+   if (!sb_min_blocksize(sb, uopt.blocksize)) {
+   udf_debug(Bad block size (%d)\n, uopt.blocksize);
+   printk(KERN_ERR udf: bad block size (%d)\n, uopt.blocksize);
goto error_out;
+   }
 
if (uopt.session == 0x)
sbi-s_session = udf_get_last_session(sb);
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] udf: kill useless file header comments for vfs method implementations

2008-02-08 Thread Christoph Hellwig
There's not need to document vfs method invocation rules, we have
Documentation/filesystems/vfs.txt and Documentation/filesystems/Locking
for that.  Also a lot of these comments where either plain wrong or
horrible out of date.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/udf/dir.c
===
--- linux-2.6.orig/fs/udf/dir.c 2008-02-09 07:42:10.0 +0100
+++ linux-2.6/fs/udf/dir.c  2008-02-09 07:42:22.0 +0100
@@ -188,32 +188,6 @@ static int do_udf_readdir(struct inode *
return 0;
 }
 
-/*
- * udf_readdir
- *
- * PURPOSE
- * Read a directory entry.
- *
- * DESCRIPTION
- * Optional - sys_getdents() will return -ENOTDIR if this routine is not
- * available.
- *
- * Refer to sys_getdents() in fs/readdir.c
- * sys_getdents() - .
- *
- * PRE-CONDITIONS
- * filpPointer to directory file.
- * buf Pointer to directory entry buffer.
- * filldir Pointer to filldir function.
- *
- * POST-CONDITIONS
- * return=0 on success.
- *
- * HISTORY
- * July 1, 1997 - Andrew E. Mileski
- * Written, tested, and released.
- */
-
 static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
struct inode *dir = filp-f_path.dentry-d_inode;
Index: linux-2.6/fs/udf/file.c
===
--- linux-2.6.orig/fs/udf/file.c2008-02-09 07:42:31.0 +0100
+++ linux-2.6/fs/udf/file.c 2008-02-09 07:43:11.0 +0100
@@ -144,40 +144,6 @@ static ssize_t udf_file_aio_write(struct
return retval;
 }
 
-/*
- * udf_ioctl
- *
- * PURPOSE
- * Issue an ioctl.
- *
- * DESCRIPTION
- * Optional - sys_ioctl() will return -ENOTTY if this routine is not
- * available, and the ioctl cannot be handled without filesystem help.
- *
- * sys_ioctl() handles these ioctls that apply only to regular files:
- * FIBMAP [requires udf_block_map()], FIGETBSZ, FIONREAD
- * These ioctls are also handled by sys_ioctl():
- * FIOCLEX, FIONCLEX, FIONBIO, FIOASYNC
- * All other ioctls are passed to the filesystem.
- *
- * Refer to sys_ioctl() in fs/ioctl.c
- * sys_ioctl() - .
- *
- * PRE-CONDITIONS
- * inode   Pointer to inode that ioctl was issued on.
- * filpPointer to file that ioctl was issued on.
- * cmd The ioctl command.
- * arg The ioctl argument [can be interpreted as a
- * user-space pointer if desired].
- *
- * POST-CONDITIONS
- * returnSuccess (=0) or an error code (=0) that
- * sys_ioctl() will return.
- *
- * HISTORY
- * July 1, 1997 - Andrew E. Mileski
- * Written, tested, and released.
- */
 int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
  unsigned long arg)
 {
@@ -225,18 +191,6 @@ int udf_ioctl(struct inode *inode, struc
return result;
 }
 
-/*
- * udf_release_file
- *
- * PURPOSE
- *  Called when all references to the file are closed
- *
- * DESCRIPTION
- *  Discard prealloced blocks
- *
- * HISTORY
- *
- */
 static int udf_release_file(struct inode *inode, struct file *filp)
 {
if (filp-f_mode  FMODE_WRITE) {
Index: linux-2.6/fs/udf/inode.c
===
--- linux-2.6.orig/fs/udf/inode.c   2008-02-09 07:42:32.0 +0100
+++ linux-2.6/fs/udf/inode.c2008-02-09 07:45:45.0 +0100
@@ -66,22 +66,7 @@ static void udf_update_extents(struct in
   struct extent_position *);
 static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int);
 
-/*
- * udf_delete_inode
- *
- * PURPOSE
- * Clean-up before the specified inode is destroyed.
- *
- * DESCRIPTION
- * This routine is called when the kernel destroys an inode structure
- * ie. when iput() finds i_count == 0.
- *
- * HISTORY
- * July 1, 1997 - Andrew E. Mileski
- * Written, tested, and released.
- *
- *  Called at the last iput() if i_nlink is zero.
- */
+
 void udf_delete_inode(struct inode *inode)
 {
truncate_inode_pages(inode-i_data, 0);
@@ -1416,21 +1401,6 @@ static mode_t udf_convert_permissions(st
return mode;
 }
 
-/*
- * udf_write_inode
- *
- * PURPOSE
- * Write out the specified inode.
- *
- * DESCRIPTION
- * This routine is called whenever an inode is synced.
- * Currently this routine is just a placeholder.
- *
- * HISTORY
- * July 1, 1997 - Andrew E. Mileski
- * Written, tested, and released.
- */
-
 int udf_write_inode(struct inode *inode, int sync)
 {
int ret;
Index: linux-2.6/fs/udf/namei.c
===
--- linux-2.6.orig/fs/udf/namei.c   2008-02-09 07:42

[PATCH 3/3] udf: move headers out include/linux/

2008-02-08 Thread Christoph Hellwig
There's really no reason to keep udf headers in include/linux as they're
not used by anything but fs/udf/.

This patch merges most of include/linux/udf_fs_i.h into fs/udf/udf_i.h,
include/linux/udf_fs_sb.h into fs/udf/udf_sb.h and
include/linux/udf_fs.h into fs/udf/udfdecl.h.

The only thing remaining in include/linux/ is a stub of udf_fs_i.h
defining the four user-visible udf ioctls.  It's also moved from
unifdef-y to headers-y because it can be included unconditionally now.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/udf/udf_i.h
===
--- linux-2.6.orig/fs/udf/udf_i.h   2008-02-09 08:27:50.0 +0100
+++ linux-2.6/fs/udf/udf_i.h2008-02-09 08:31:34.0 +0100
@@ -1,10 +1,32 @@
-#ifndef __LINUX_UDF_I_H
-#define __LINUX_UDF_I_H
+#ifndef _UDF_I_H
+#define _UDF_I_H
+
+struct udf_inode_info {
+   struct timespec i_crtime;
+   /* Physical address of inode */
+   kernel_lb_addr  i_location;
+   __u64   i_unique;
+   __u32   i_lenEAttr;
+   __u32   i_lenAlloc;
+   __u64   i_lenExtents;
+   __u32   i_next_alloc_block;
+   __u32   i_next_alloc_goal;
+   unsignedi_alloc_type : 3;
+   unsignedi_efe : 1;
+   unsignedi_use : 1;
+   unsignedi_strat4096 : 1;
+   unsignedreserved : 26;
+   union {
+   short_ad*i_sad;
+   long_ad *i_lad;
+   __u8*i_data;
+   } i_ext;
+   struct inode vfs_inode;
+};
 
-#include linux/udf_fs_i.h
 static inline struct udf_inode_info *UDF_I(struct inode *inode)
 {
return list_entry(inode, struct udf_inode_info, vfs_inode);
 }
 
-#endif /* !defined(_LINUX_UDF_I_H) */
+#endif /* _UDF_I_H) */
Index: linux-2.6/include/linux/Kbuild
===
--- linux-2.6.orig/include/linux/Kbuild 2008-02-09 08:27:50.0 +0100
+++ linux-2.6/include/linux/Kbuild  2008-02-09 08:28:01.0 +0100
@@ -150,6 +150,7 @@ header-y += tiocl.h
 header-y += tipc.h
 header-y += tipc_config.h
 header-y += toshiba.h
+header-y += udf_fs_i.h
 header-y += ultrasound.h
 header-y += un.h
 header-y += utime.h
@@ -336,7 +337,6 @@ unifdef-y += time.h
 unifdef-y += timex.h
 unifdef-y += tty.h
 unifdef-y += types.h
-unifdef-y += udf_fs_i.h
 unifdef-y += udp.h
 unifdef-y += uinput.h
 unifdef-y += uio.h
Index: linux-2.6/include/linux/udf_fs_i.h
===
--- linux-2.6.orig/include/linux/udf_fs_i.h 2008-02-09 08:27:50.0 
+0100
+++ linux-2.6/include/linux/udf_fs_i.h  2008-02-09 08:28:01.0 +0100
@@ -9,41 +9,10 @@
  * ftp://prep.ai.mit.edu/pub/gnu/GPL
  * Each contributing author retains all rights to their own work.
  */
-
 #ifndef _UDF_FS_I_H
 #define _UDF_FS_I_H 1
 
-#ifdef __KERNEL__
-
-struct udf_inode_info
-{
-   struct timespec i_crtime;
-   /* Physical address of inode */
-   kernel_lb_addr  i_location;
-   __u64   i_unique;
-   __u32   i_lenEAttr;
-   __u32   i_lenAlloc;
-   __u64   i_lenExtents;
-   __u32   i_next_alloc_block;
-   __u32   i_next_alloc_goal;
-   unsignedi_alloc_type : 3;
-   unsignedi_efe : 1;
-   unsignedi_use : 1;
-   unsignedi_strat4096 : 1;
-   unsignedreserved : 26;
-   union
-   {
-   short_ad*i_sad;
-   long_ad *i_lad;
-   __u8*i_data;
-   } i_ext;
-   struct inode vfs_inode;
-};
-
-#endif
-
 /* exported IOCTLs, we have 'l', 0x40-0x7f */
-
 #define UDF_GETEASIZE   _IOR('l', 0x40, int)
 #define UDF_GETEABLOCK  _IOR('l', 0x41, void *)
 #define UDF_GETVOLIDENT _IOR('l', 0x42, void *)
Index: linux-2.6/fs/udf/file.c
===
--- linux-2.6.orig/fs/udf/file.c2008-02-09 08:27:59.0 +0100
+++ linux-2.6/fs/udf/file.c 2008-02-09 08:28:01.0 +0100
@@ -27,7 +27,6 @@
 
 #include udfdecl.h
 #include linux/fs.h
-#include linux/udf_fs.h
 #include asm/uaccess.h
 #include linux/kernel.h
 #include linux/string.h /* memset */
Index: linux-2.6/fs/udf/ialloc.c
===
--- linux-2.6.orig/fs/udf/ialloc.c  2008-02-09 08:27:50.0 +0100
+++ linux-2.6/fs/udf/ialloc.c   2008-02-09 08:28:01.0 +0100
@@ -21,7 +21,6 @@
 #include udfdecl.h
 #include linux/fs.h
 #include linux/quotaops.h
-#include linux/udf_fs.h
 #include linux/sched.h
 #include linux/slab.h
 
Index

Re: [NFS] [PATCH] Make UDF exportable

2008-02-06 Thread Christoph Hellwig
On Wed, Feb 06, 2008 at 09:58:02PM +0100, Rasmus Rohde wrote:
 Probably not. I just tested that I could read files and navigate the
 directory structure. However looking into UDF I think you are right - it
 will fail.
 I have extended udf_find_entry() to do an explicit check based on
 fileCharacteristics as you propose.
 How do I actually test this case?

Testing this is pretty hard.  You export a filesystem, then cd somewhere
deep into a directory hiearchy in there.  Then unexport the filesystem
and unmount on the server.  mount it back on the server, export it again
and do something with a file from the directory you've cd into before
the unmount.  Make sure you have a printk in your get_parent method
to make sure you're really hitting it.

Btw, I think it would be nicer to opencode the .. lookup in get_parent
instead of changing udf_find_entry.  The lookup for .. is not needed
by anything else, and get_parent only looks for it so it's a natural
place to opencode it there.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] reiserfs: use open_bdev_excl

2008-02-06 Thread Christoph Hellwig
On Wed, Dec 26, 2007 at 04:31:01PM +0100, Christoph Hellwig wrote:
 Use the proper helper to open a blockdevice by name for filesystem
 use, this makes sure it's properly claimed (also added for open-by-number)
 and gets rid of the struct file abuse.
 
 Tested by mounting a reiserfs filesystem with external journal.

Folks, what do we do with this patch?  It's been out for more than a
month but didn't actually get picked up in any tree.  I'd really like
to see this going in soon.

 Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]
 
 Index: linux-2.6-xfs/fs/reiserfs/journal.c
 ===
 --- linux-2.6-xfs.orig/fs/reiserfs/journal.c  2007-12-13 18:55:40.0 
 +0100
 +++ linux-2.6-xfs/fs/reiserfs/journal.c   2007-12-26 15:13:22.0 
 +0100
 @@ -2574,11 +2574,9 @@ static int release_journal_dev(struct su
  
   result = 0;
  
 - if (journal-j_dev_file != NULL) {
 - result = filp_close(journal-j_dev_file, NULL);
 - journal-j_dev_file = NULL;
 - journal-j_dev_bd = NULL;
 - } else if (journal-j_dev_bd != NULL) {
 + if (journal-j_dev_bd != NULL) {
 + if (journal-j_dev_bd-bd_dev != super-s_dev)
 + bd_release(journal-j_dev_bd);
   result = blkdev_put(journal-j_dev_bd);
   journal-j_dev_bd = NULL;
   }
 @@ -2603,7 +2601,6 @@ static int journal_init_dev(struct super
   result = 0;
  
   journal-j_dev_bd = NULL;
 - journal-j_dev_file = NULL;
   jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
   new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super-s_dev;
  
 @@ -2620,35 +2617,34 @@ static int journal_init_dev(struct super
cannot init journal device '%s': %i,
__bdevname(jdev, b), result);
   return result;
 - } else if (jdev != super-s_dev)
 + } else if (jdev != super-s_dev) {
 + result = bd_claim(journal-j_dev_bd, journal);
 + if (result) {
 + blkdev_put(journal-j_dev_bd);
 + return result;
 + }
 +
   set_blocksize(journal-j_dev_bd, super-s_blocksize);
 + }
 +
   return 0;
   }
  
 - journal-j_dev_file = filp_open(jdev_name, 0, 0);
 - if (!IS_ERR(journal-j_dev_file)) {
 - struct inode *jdev_inode = journal-j_dev_file-f_mapping-host;
 - if (!S_ISBLK(jdev_inode-i_mode)) {
 - reiserfs_warning(super, journal_init_dev: '%s' is 
 -  not a block device, jdev_name);
 - result = -ENOTBLK;
 - release_journal_dev(super, journal);
 - } else {
 - /* ok */
 - journal-j_dev_bd = I_BDEV(jdev_inode);
 - set_blocksize(journal-j_dev_bd, super-s_blocksize);
 - reiserfs_info(super,
 -   journal_init_dev: journal device: %s\n,
 -   bdevname(journal-j_dev_bd, b));
 - }
 - } else {
 - result = PTR_ERR(journal-j_dev_file);
 - journal-j_dev_file = NULL;
 + journal-j_dev_bd = open_bdev_excl(jdev_name, 0, journal);
 + if (IS_ERR(journal-j_dev_bd)) {
 + result = PTR_ERR(journal-j_dev_bd);
 + journal-j_dev_bd = NULL;
   reiserfs_warning(super,
journal_init_dev: Cannot open '%s': %i,
jdev_name, result);
 + return result;
   }
 - return result;
 +
 + set_blocksize(journal-j_dev_bd, super-s_blocksize);
 + reiserfs_info(super,
 +   journal_init_dev: journal device: %s\n,
 +   bdevname(journal-j_dev_bd, b));
 + return 0;
  }
  
  /**
 Index: linux-2.6-xfs/include/linux/reiserfs_fs_sb.h
 ===
 --- linux-2.6-xfs.orig/include/linux/reiserfs_fs_sb.h 2007-12-13 
 19:06:58.0 +0100
 +++ linux-2.6-xfs/include/linux/reiserfs_fs_sb.h  2007-12-26 
 15:13:22.0 +0100
 @@ -177,7 +177,6 @@ struct reiserfs_journal {
   struct reiserfs_journal_cnode *j_last;  /* newest journal block */
   struct reiserfs_journal_cnode *j_first; /*  oldest journal block.  
 start here for traverse */
  
 - struct file *j_dev_file;
   struct block_device *j_dev_bd;
   int j_1st_reserved_block;   /* first block on s_dev of reserved 
 area journal */
  
---end quoted text---
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] reiserfs: use open_bdev_excl

2008-02-06 Thread Christoph Hellwig
On Wed, Feb 06, 2008 at 09:16:27PM -0800, Andrew Morton wrote:
 On Thu, 7 Feb 2008 05:45:13 +0100 Christoph Hellwig [EMAIL PROTECTED] wrote:
 
  On Wed, Dec 26, 2007 at 04:31:01PM +0100, Christoph Hellwig wrote:
   Use the proper helper to open a blockdevice by name for filesystem
   use, this makes sure it's properly claimed (also added for open-by-number)
   and gets rid of the struct file abuse.
   
   Tested by mounting a reiserfs filesystem with external journal.
  
  Folks, what do we do with this patch?  It's been out for more than a
  month but didn't actually get picked up in any tree.
 
 It's still sitting in the great pile of things I got sent over Christmas
 and haven't looked at yet.  It didn't look like a bugfix.

Well, it's fixing that reiserds doesn't bd_claim it's journal device so
people can open the block device with O_EXCL against the documetned
semantics.  It's probably also fixing various corner cases that
open_bdev_excl deals with and a hand-crafted filp_open doesn't.

   I'd really like
  to see this going in soon.
 
 How come?

I just hate sitting on a stack of patches.  Even more so if I'd like to
see the public API removed in there eventually go away.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [NFS] [PATCH] Make UDF exportable

2008-02-05 Thread Christoph Hellwig
On Wed, Jan 30, 2008 at 09:53:24PM +0100, Rasmus Rohde wrote:
 I've cooked together a patch for making UDF exportable.

Thanks, I know some people have been waiting for this for quite a while.
Please make sure Jan Kara who's the new udf maintainer and linux-fsdevel
where we discuss general filesystem related issue for future revisions
of the patch.

 It is based on the code found in ISO fs. Since I am far from an expert
 in this area bugs may be present.

isofs might not be the very best example since it's an odd filesystem,
but then so is udf.  I'll go through your patch in a little more detail
below, but it looks quite reasonable.

 +static struct dentry *udf_export_get_parent(struct dentry *child)

Any reason this is not called udf_get_parent to follow the scheme
in most filesystems?

 + lock_kernel();
 + if (udf_find_entry(child-d_inode, dotdot, fibh, cfi)) {
 + if (fibh.sbh != fibh.ebh)
 + brelse(fibh.ebh);
 + brelse(fibh.sbh);
 + 
 + inode = udf_iget(child-d_inode-i_sb,
 +  lelb_to_cpu(cfi.icb.extLocation));
 + if (!inode) {
 + unlock_kernel();
 + return ERR_PTR(-EACCES);
 + }
 + } else {
 + unlock_kernel();
 + return ERR_PTR(-EACCES);
 + }
 + unlock_kernel();

This if/else block looks little odd, and following the locking is a bit
hard.  What about doing it like the following:

lock_kernel();
if (!udf_find_entry(child-d_inode, dotdot, fibh, cfi))
goto out_unlock;

if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh);
brelse(fibh.sbh);

inode = udf_iget(child-d_inode-i_sb,
 lelb_to_cpu(cfi.icb.extLocation));
if (!inode)
goto out_unlock;
unlock_kernel();

parent = d_alloc_anon(inode);
if (!parent) {
iput(inode);
parent = ERR_PTR(-ENOMEM);
}

return parent;
 out_unlock:
unlock_kernel();
return ERR_PTR(-EACCESS);
}


 +static struct dentry *
 +udf_export_iget(struct super_block *sb, u32 block,
 + u16 offset, __u32 generation)

to follow other filesystems this should be called
udf_nfs_get_inode.  Also please decide if you want to put the static
and return type on the same line or on a separate one.  Having it on
the same one is documented in Documentation/Codingstyle but separate
ones are acceptable aswell.  Just make sure to stick to either one :)

 +{
 + struct inode *inode;
 + struct dentry *result;
 + kernel_lb_addr loc;
 +
 + if (block == 0)
 + return ERR_PTR(-ESTALE);
 +
 + loc.logicalBlockNum = block;
 + loc.partitionReferenceNum = offset;
 + inode = udf_iget(sb, loc);
 +
 + if (inode == NULL)
 + return ERR_PTR(-ENOMEM);
 +
 + if (is_bad_inode(inode)
 + || (generation  inode-i_generation != generation))
 + {

it would be better to introduce a version of udf_iget that can check
the generation and return an error instead of having to check this
later.  If you don't think you're up to modifying code we could do
this later on, though.  In this case please note this in the patch
description and fix up the above formatting to read something like:

if (is_bad_inode(inode) ||
(generation  inode-i_generation != generation)) {

 +static struct dentry *udf_fh_to_dentry(struct super_block *sb,
 + struct fid *fid, int fh_len, int fh_type)
 +{
 + struct udf_fid *ufid = (struct udf_fid *)fid;
 +
 + if (fh_len  3 || fh_type  2)
 + return NULL;

It would be useful if you could add symbolic constants for the
two fh types you add and chose values not yet used by other filesystems,
e.g. 0x51 and 0x52.  This will help people sniffing the nfs on the
wire protocol to understand what file handle they're dealing with.

Also you migh want to make the fh_len check more explicit and check
that it's either 3 or 5 which is the only fhs you actually generate.

 +static struct dentry *udf_fh_to_parent(struct super_block *sb,
 + struct fid *fid, int fh_len, int fh_type)
 +{
 + struct udf_fid *ufid = (struct udf_fid *)fid;
 +
 + if (fh_type != 2)
 + return NULL;

and a check for len == 5 here.

 +
 + return udf_export_iget(sb,
 + fh_len  2 ? ufid-parent_block : 0,
 + ufid-parent_partref,
 + fh_len  4 ? ufid-parent_generation : 0);

and you can remove these checks as you only end up here with len == 5
fhs.

Also it would be nice if you could add your fid type to the union in
include/linux/exportfs.h and use the union member.  The symbolic names
for the FH types should go into enum fid_type with a short comment
describing them.

Thanks for all this work!
-
To unsubscribe from this list: send the line unsubscribe 

Re: projected date for mount.cifs to support DFS junction points

2008-02-05 Thread Christoph Hellwig
On Fri, Jan 11, 2008 at 09:07:49AM +, Christoph Hellwig wrote:
 If you want to get it into 2.6.25 get it out for review on -fsdevel
 ASAP.  2.6.24 is almost done and it needs to be in acceptable state
 before 2.6.25 opens.

So I've done an extensive review now, but the patches (or rather an
incomplete set, that's even dumber) made it into Linus tree without
things beeing addressed.  That's not how it's supposed to work.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 0/3] add perform_write to a_ops

2008-02-04 Thread Christoph Hellwig
On Mon, Feb 04, 2008 at 06:04:10PM +0100, Miklos Szeredi wrote:
 a_ops-perform_write() was left out from Nick Piggin's new a_ops
 patchset, as it was non-essential, and postponed for later inclusion.
 
 This short series reintroduces it, but only adds the fuse
 implementation and not simple_perform_write(), which I'm not sure
 would be a significant improvement.
 
 This allows larger than 4k buffered writes for fuse, which is one of
 the most requested features.
 
 This goes on top of the fuse: writable mmap patches.

Please don't do this, but rather implement your own .aio_write.  There's
very little in generic_file_aio_write that wouldn't be handle by
-perform_write and we should rather factor those up or move to higher
layers than adding this ill-defined abstraction.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 0/3] add perform_write to a_ops

2008-02-04 Thread Christoph Hellwig
On Mon, Feb 04, 2008 at 09:52:06PM +0100, Miklos Szeredi wrote:
 Moving up to higher layers might not be possible, due to lock/unlock
 of i_mutex being inside generic_file_aio_write().

Well some bits can be moved up.  Here's my grand plan which I plan
to implement once I get some time for it (or let someone else do
if they beat me):

 - generic_segment_checks goes to fs/read_write.c before caling into
   the filesystem
 - dito for vfs_check_frozen
 - generic_write_checks is a suitable helper already
 - dito for remove_suid
 - dito for file_update_time
 - after that there's not a whole lot left in generic_file_aio_write,
   except for direct I/O handling which will probably be very fs-specific
   if you have your own buffered I/O code

generic_file_buffered_write is an almost trivial wrapper around what's
-perform_write in Nick's earlier patches and a helper for the syncing
activity.



 
 But with fuse being the only user, it's not a huge issue duplicating
 some code.
 
 Nick, were there any other candidates, that would want to use such an
 interface in the future?
 
 Thanks,
 Miklos
 -
 To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
---end quoted text---
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] ext3 freeze feature

2008-01-26 Thread Christoph Hellwig
On Fri, Jan 25, 2008 at 09:42:30PM +0900, Takashi Sato wrote:
 Hi,
 
 I am also wondering whether we should have system call(s) for these:
 
 On Jan 25, 2008 12:59 PM, Takashi Sato [EMAIL PROTECTED] wrote:
 +   case EXT3_IOC_FREEZE: {
 
 +   case EXT3_IOC_THAW: {
 
 And just convert XFS to use them too?
 
 I think it is reasonable to implement it as the generic system call, as you 
 said.
 Does XFS folks think so?

Given that XFS has implemented the ioctls for such a long time it might
make more sense to simply move the ioctl implementation to fs/ioctl.c
so it applies to all filesystem.  No need to add a new syscall when the
equivalent-functionality ioctls have to be supported forever anyway.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Patch] document ext3 requirements (was Re: [RFD] Incremental fsck)

2008-01-16 Thread Christoph Hellwig
On Wed, Jan 16, 2008 at 08:43:25AM +1100, David Chinner wrote:
 ext3 is not the only filesystem that will have trouble due to
 volatile write caches. We see problems often enough with XFS
 due to volatile write caches that it's in our FAQ:

In fact it will hit every filesystem.  A write-back cache that can't
be forced to write back bythe filesystem will cause corruption on
uncontained power loss, period.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 4/8] revoke: core code V7

2008-01-15 Thread Christoph Hellwig
On Tue, Jan 15, 2008 at 04:14:54PM +0100, Peter Zijlstra wrote:
 Humm, we were trying to get rid of file_list_lock(), this puts up
 another user of the sb file list.
 
 Also, that loop looks horribly expensive: n*(1+m); where n is the list
 size, and m the number of matching fds.
 
 Granted, I see no other options either.

Something like the loop above is not going to go in for sure.  Once we
get rid of the sb-s_files we can put the list_head in struct file to
new use eventually if we don't want to get rid of it.  E.g. and
per-inode list would be much better than the per-superblock one and
would regularize what the tty driver is doing.

But I'm not too interesting in hashing out these details currently,
my primary concern is to get the per-mount r/o plus fallout like the
correct remount r/o and file_list_lock removal in and stable first.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [linux-cifs-client] review 4, was Re: projected date for mount.cifs to support DFS junction points

2008-01-14 Thread Christoph Hellwig
On Mon, Jan 14, 2008 at 04:15:05PM +0300, Q (Igor Mammedov) wrote:
  +   dput(nd-dentry);
  +   nd-dentry = dget(dentry);
  +   if (d_mountpoint(nd-dentry))
  +   goto out_follow;
  
  A link should never be a mountpoint.
 
 why link? after patch 5 are applied DFS junction point becomes directory
 instead of link. That is what has been done in NFS code.

True, this is the -follow_link on directory hack.

 Actually I copy  pasted it from NFS code ...
 fs/nfs/namespace.c:nfs_follow_mountpoint
 
 I've tried to do submount/referral machinery in NFS code way.

Okay, and that came from afs.  I really think we should take large
parts of this back into the VFS because it's just to fragile to
be duplicated in various filesystems.  Probably not a blocker for
your patch but I'll keep an eye on consolidating this back into
the core.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


review 1, was Re: projected date for mount.cifs to support DFS junction points

2008-01-13 Thread Christoph Hellwig
Unfortunately I couldn't find an mbox archive of the cifs client list
anywhere, so I'll send you the review in reply to this mail, with
one reply per patch.

This is for the first patch:



+ *  fs/cifs/cifs_dfs_ref.c

Please don't mention file names in top of file comments, they serve no
use and get out of sync far too easily.  (Btw, lots of these comment
apply to multiple files and some or all of the patches, I'm not going
to repeat them when it happens again)

+ *   This library is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Lesser General Public License as published
+ *   by the Free Software Foundation; either version 2.1 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This library is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU Lesser General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Lesser General Public License
+ *   along with this library; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

I strikes me as odd that this is LGPL, but I noticed other files in
fs/cifs/ have this aswell.  We don't ship a copy of the LGPL with the
kernel which is at least against this comment if not even against the
license.  And it'll revert to GPLv2 as part of the kernel anyway,
so it would be much easier if you just declared the code GPLv2.

+
+/* Resolves server name to ip address.
+ * input:
+ * unc - server UNC
+ * output:
+ * *ip_addr - pointer to server ip, caller responcible for freeing it.
+ * return 0 on success
+ */

This should be a kerneldoc comment.

+static int
+cifs_resolve_server_name_to_ip(const char *unc, char **ip_addr) {

opening curley brace goes on a line of it's own.

+   int rc = -EAGAIN;
+   struct key *rkey;
+   char *name;
+   int len;
+
+   if ((!ip_addr) || (!unc))
+   return -EINVAL;

Useless braces.  Should be:

if (!ip_addr || !unc)
return -EINVAL;

+   rkey = request_key(key_type_cifs_resolver, name, );
+   if (!IS_ERR(rkey)) {
+   len = strlen(rkey-payload.data);
+   *ip_addr = kmalloc(len+1, GFP_KERNEL);
+   if (*ip_addr) {
+   memcpy(*ip_addr, rkey-payload.data, len);
+   (*ip_addr)[len] = '\0';
+   cFYI(1, (%s: resolved: %s to %s, __FUNCTION__,
+   rkey-description,
+   *ip_addr
+   ));
+   rc = 0;
+   } else {
+   rc = -ENOMEM;
+   }
+   key_put(rkey);
+   } else {
+   cERROR(1, (%s: unable to resolve: %s, __FUNCTION__, name));
+   }

please use proper goto based unwiding instea of the if-else galore.

+#ifndef _CIFS_DFS_REF_H
+#define _CIFS_DFS_REF_H
+
+#ifdef __KERNEL__
+extern struct key_type key_type_cifs_resolver;
+#endif /* KERNEL */

No need for __KERNEL__ ifdefs here.

+#ifdef CONFIG_CIFS_DFS_UPCALL
+   rc = register_key_type(key_type_cifs_resolver);
+   if (rc)
+   goto out_unregister_key_type;
+#endif

Instead of the ifdef mess please put helpers like
register_resolver_key() into the conditionally compiled file and stub them
out in the header if the config option is not set.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


review 2, was Re: projected date for mount.cifs to support DFS junction points

2008-01-13 Thread Christoph Hellwig
+struct dfs_info3_param {
+   int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/
+   int PathConsumed;
+   int server_type;
+   int ref_flag;
+   char *path_name;
+   char *node_name;
+};

Please avoid mixed case struct member names.

+
+static inline void init_dfs_info_param(struct dfs_info3_param *param)
+{
+   memset(param, 0, sizeof(struct dfs_info3_param));
+}

And open-coded memset at the caller would be more readable..

+
+static inline void free_dfs_info_param(struct dfs_info3_param *param)
+{
+   if (param) {
+   kfree(param-path_name);
+   kfree(param-node_name);
+   kfree(param);
+   }
+}

This one is completely unused.

--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -3879,8 +3879,8 @@ GetInodeNumOut:
 int
 CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
const unsigned char *searchName,
-   unsigned char **targetUNCs,
-   unsigned int *number_of_UNC_in_array,
+   struct dfs_info3_param **targetNode,
+   unsigned int *number_of_Nodes_in_array,
const struct nls_table *nls_codepage, int remap)

This function already was huge before the patch and grows even more.
Please consider refactoring it into small, readable helpers.


+   cFYI(1,
+   (Decoding GetDFSRefer response BCC: %d  Offset %d,
+pSMBr-ByteCount, data_offset));

Very strange formatting..

+/* BB: Probably we do not need this function any more.
+ * Anyway it never worked. May be one day we well need it.
+ */
 int
 connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
const char *old_path, const struct nls_table *nls_codepage,
int remap)
 {
+   /*

Please just remove such dead code entirely.  If people want to resurrect
it for some reason they still have the git archives.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


review 3, was Re: projected date for mount.cifs to support DFS junction points

2008-01-13 Thread Christoph Hellwig
+#ifdef CONFIG_CIFS_DFS_UPCALL
+   /* copy mount params to sb for use in submounts */
+   /* BB: should we move this after the mount so we
+* do not have to do the copy on failed mounts?
+* BB: May be it is better to do simple copy before
+* complex operation (mount), and in case of fail
+* just exit instead of doing mount and attempting
+* undo it if this copy fails?*/
+   len = strlen(data);
+   cifs_sb-mountdata = kzalloc(len + 1, GFP_KERNEL);
+   if (cifs_sb-mountdata == NULL) {
+   kfree(sb-s_fs_info);
+   sb-s_fs_info = NULL;
+   return -ENOMEM;
+   }
+   strncpy(cifs_sb-mountdata, data, len + 1);
+   cifs_sb-mountdata[len] = '\0';
+#endif

Please split the mount data handling into nice helpers that can
be stubbed out for !CONFIG_CIFS_DFS_UPCALL.

-static struct file_system_type cifs_fs_type = {
+struct file_system_type cifs_fs_type = {

This isn't actually used outside of cifsfs.c in this patch, so it should
not be made non-static here.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] fast file mapping for loop

2008-01-10 Thread Christoph Hellwig
On Thu, Jan 10, 2008 at 12:42:25PM +1100, Nick Piggin wrote:
  So how does it work? Instead of punting IO to a thread and passing it
  through the page cache, we instead attempt to send the IO directly to the
  filesystem block that it maps to.
 
 You told Christoph that just using direct-IO from kernel still doesn't
 give you the required behaviour... What about queueing the IO directly
 *and* using direct-IO? I guess it still has to go through the underlying
 filesystem, but that's probably a good thing.

We defintively need to go through the filesystem for I/O submission,
and also for I/O completion.  Thinking of the async submission might be
what Peter actually implemented for his network swapping patches as
you really wouldn't want to write it out synchronously.


Peter, any chance you could chime in here?
 
  loop maintains a prio tree of known 
  extents in the file (populated lazily on demand, as needed).
 
 Just a quick question (I haven't looked closely at the code): how come
 you are using a prio tree for extents? I don't think they could be
 overlapping?

IMHO this shouldn't be done in the loop driver anyway.  Filesystems have
their own effricient extent lookup trees (well, at least xfs and btrfs
do), and we should leverage that instead of reinventing it.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] fast file mapping for loop

2008-01-10 Thread Christoph Hellwig
On Thu, Jan 10, 2008 at 09:44:57AM +0100, Jens Axboe wrote:
  IMHO this shouldn't be done in the loop driver anyway.  Filesystems have
  their own effricient extent lookup trees (well, at least xfs and btrfs
  do), and we should leverage that instead of reinventing it.
 
 Completely agree, it's just needed right now for this solution since all
 we have is a crappy bmap() interface to get at those mappings.

So let's fix the interface instead of piling crap ontop of it.  As I
said I think Peter has something to start with so let's beat on it
until we have something suitable.   If we aren't done by end of Feb
I'm happy to host a hackfest to get it sorted around the fs/storage
summit..

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [UNIONFS] 00/29 Unionfs and related patches pre-merge review (v2)

2008-01-10 Thread Christoph Hellwig
On Thu, Jan 10, 2008 at 09:59:19AM -0500, Erez Zadok wrote:
 
 Dear Linus, Al, Christoph, and Andrew,
 
 As per your request, I'm posting for review the unionfs code (and related
 code) that's in my korg tree against mainline (v2.6.24-rc7-71-gfd0b45d).
 This is in preparation for merge in 2.6.25.

Huh?  There's still aboslutely not fix to the underlying problems of
the whole idea.   I think we made it pretty clear that unionfs is not
the way to go, and that we'll get the union mount patches clear once
the per-mountpoint r/o and unprivilegued mount patches series are in
and stable.


-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] fix reservation discarding in affs

2008-01-10 Thread Christoph Hellwig
On Thu, Feb 10, 2005 at 01:57:04PM +0100, Roman Zippel wrote:
  affs already does it in a) and a few other places, so adding it to
  affs_clear_inode should make it behave fine.   Also move the truncate
  from affs_put_inode with the racy i_count check to affs_clear_inode.
  This also avoids the need to take the inode semaphore as the inode can't
  be accessed from other threads anymore.
 
 Looks fine.
 There is still somewhat the problem that I don't want to hold on to the 
 preallocation for ages for directories and very useful would be a 
 callback to flush preallocation when the disk becomes full. Previously I 
 tried it via sync, but maybe someone has an idea how to do this properly.

For some reason this never got any traction.  Below is a respin against
curently mainline.  The preallocations are still released later so no
progress on that end.  Because this is the last instance of -put_inode
I'd like to move forward on getting rid of it.

Is there any chance you could either send me a affs image to run fsx
on it or do it yourself?


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/affs/affs.h
===
--- linux-2.6.orig/fs/affs/affs.h   2008-01-10 10:46:07.0 +0100
+++ linux-2.6/fs/affs/affs.h2008-01-10 10:46:08.0 +0100
@@ -170,7 +170,6 @@ extern int  affs_rename(struct inode *old
 extern unsigned longaffs_parent_ino(struct inode *dir);
 extern struct inode*affs_new_inode(struct inode *dir);
 extern int  affs_notify_change(struct dentry *dentry, 
struct iattr *attr);
-extern void affs_put_inode(struct inode *inode);
 extern void affs_drop_inode(struct inode *inode);
 extern void affs_delete_inode(struct inode *inode);
 extern void affs_clear_inode(struct inode *inode);
Index: linux-2.6/fs/affs/inode.c
===
--- linux-2.6.orig/fs/affs/inode.c  2008-01-10 10:46:07.0 +0100
+++ linux-2.6/fs/affs/inode.c   2008-01-10 16:06:25.0 +0100
@@ -239,15 +239,10 @@ out:
 }
 
 void
-affs_put_inode(struct inode *inode)
+affs_drop_inode(struct inode *inode)
 {
-   pr_debug(AFFS: put_inode(ino=%lu, nlink=%u)\n, inode-i_ino, 
inode-i_nlink);
affs_free_prealloc(inode);
-}
 
-void
-affs_drop_inode(struct inode *inode)
-{
mutex_lock(inode-i_mutex);
if (inode-i_size != AFFS_I(inode)-mmu_private)
affs_truncate(inode);
Index: linux-2.6/fs/affs/super.c
===
--- linux-2.6.orig/fs/affs/super.c  2008-01-10 10:46:07.0 +0100
+++ linux-2.6/fs/affs/super.c   2008-01-10 10:46:08.0 +0100
@@ -115,7 +115,6 @@ static const struct super_operations aff
.destroy_inode  = affs_destroy_inode,
.read_inode = affs_read_inode,
.write_inode= affs_write_inode,
-   .put_inode  = affs_put_inode,
.drop_inode = affs_drop_inode,
.delete_inode   = affs_delete_inode,
.clear_inode= affs_clear_inode,
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH][RFC] fast file mapping for loop

2008-01-09 Thread Christoph Hellwig
On Wed, Jan 09, 2008 at 09:52:32AM +0100, Jens Axboe wrote:
 - The file block mappings must not change while loop is using the file.
   This means that we have to ensure exclusive access to the file and
   this is the bit that is currently missing in the implementation. It
   would be nice if we could just do this via open(), ideas welcome...

And the way this is done is simply broken.  It means you have to get
rid of things like delayed or unwritten hands beforehand, it'll be
a complete pain for COW or non-block backed filesystems.

The right way to do this is to allow direct I/O from kernel sources
where the filesystem is in-charge of submitting the actual I/O after
the pages are handed to it.  I think Peter Zijlstra has been looking
into something like that for swap over nfs.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ufs: remove unneeded ufs_put_inode prototype

2008-01-02 Thread Christoph Hellwig

Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/ufs/ufs.h
===
--- linux-2.6.orig/fs/ufs/ufs.h 2007-12-31 10:12:42.0 +0100
+++ linux-2.6/fs/ufs/ufs.h  2007-12-31 10:12:46.0 +0100
@@ -107,7 +107,6 @@ extern struct inode * ufs_new_inode (str
 
 /* inode.c */
 extern void ufs_read_inode (struct inode *);
-extern void ufs_put_inode (struct inode *);
 extern int ufs_write_inode (struct inode *, int);
 extern int ufs_sync_inode (struct inode *);
 extern void ufs_delete_inode (struct inode *);
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ext2: remove unused ext2_put_inode prototype

2008-01-02 Thread Christoph Hellwig

Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/ext2/ext2.h
===
--- linux-2.6.orig/fs/ext2/ext2.h   2007-12-31 10:12:12.0 +0100
+++ linux-2.6/fs/ext2/ext2.h2007-12-31 10:12:15.0 +0100
@@ -126,7 +126,6 @@ extern unsigned long ext2_count_free (st
 /* inode.c */
 extern void ext2_read_inode (struct inode *);
 extern int ext2_write_inode (struct inode *, int);
-extern void ext2_put_inode (struct inode *);
 extern void ext2_delete_inode (struct inode *);
 extern int ext2_sync_inode (struct inode *);
 extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] Remove BKL from fs/locks.c

2007-12-30 Thread Christoph Hellwig
On Sat, Dec 29, 2007 at 11:16:15PM -0700, Matthew Wilcox wrote:

 It seems to work well enough, but I haven't run any serious stress  
 tests on it.  This implementation uses one spinlock to protect both lock
 lists and all the i_flock chains.  It doesn't seem worth splitting up
 the locking any further.

If people are really having any kind of scalability problems with this
still it should be quite trivial to make the file_lock_list and
blocked_list aswel as the new file_lock_lock per-superblock as file
and thus locks never move between superblocks.  In fact I'd probably
do this even without scalability concerns just to make our fs data
structures nice per-superblock.

 I had to move one memory allocation out from under the file_lock_lock.
 I hope I got that logic right.  I'm rather tempted to split out the
 find_conflict algorithm from that function into something that can be
 called separately for the FL_ACCESS case.

Yes, splitting that out makes a lot of sense.  Should be a separate
patch, though.


 +static inline void lock_flocks(void)
 +{
 + spin_lock(file_lock_lock);
 +}
 +
 +static inline void unlock_flocks(void)
 +{
 + spin_unlock(file_lock_lock);
 +}

I'd rather not introduce this wrappers, they only obsfucated what's
really going on.

 + if (found) {
 + unlock_flocks();
   cond_resched();
 + lock_flocks();
 + }

There's a cond_resched_lock that only drops the lock in case we really
need to block.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] reiserfs: use open_bdev_excl

2007-12-26 Thread Christoph Hellwig
Use the proper helper to open a blockdevice by name for filesystem
use, this makes sure it's properly claimed (also added for open-by-number)
and gets rid of the struct file abuse.

Tested by mounting a reiserfs filesystem with external journal.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6-xfs/fs/reiserfs/journal.c
===
--- linux-2.6-xfs.orig/fs/reiserfs/journal.c2007-12-13 18:55:40.0 
+0100
+++ linux-2.6-xfs/fs/reiserfs/journal.c 2007-12-26 15:13:22.0 +0100
@@ -2574,11 +2574,9 @@ static int release_journal_dev(struct su
 
result = 0;
 
-   if (journal-j_dev_file != NULL) {
-   result = filp_close(journal-j_dev_file, NULL);
-   journal-j_dev_file = NULL;
-   journal-j_dev_bd = NULL;
-   } else if (journal-j_dev_bd != NULL) {
+   if (journal-j_dev_bd != NULL) {
+   if (journal-j_dev_bd-bd_dev != super-s_dev)
+   bd_release(journal-j_dev_bd);
result = blkdev_put(journal-j_dev_bd);
journal-j_dev_bd = NULL;
}
@@ -2603,7 +2601,6 @@ static int journal_init_dev(struct super
result = 0;
 
journal-j_dev_bd = NULL;
-   journal-j_dev_file = NULL;
jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super-s_dev;
 
@@ -2620,35 +2617,34 @@ static int journal_init_dev(struct super
 cannot init journal device '%s': %i,
 __bdevname(jdev, b), result);
return result;
-   } else if (jdev != super-s_dev)
+   } else if (jdev != super-s_dev) {
+   result = bd_claim(journal-j_dev_bd, journal);
+   if (result) {
+   blkdev_put(journal-j_dev_bd);
+   return result;
+   }
+
set_blocksize(journal-j_dev_bd, super-s_blocksize);
+   }
+
return 0;
}
 
-   journal-j_dev_file = filp_open(jdev_name, 0, 0);
-   if (!IS_ERR(journal-j_dev_file)) {
-   struct inode *jdev_inode = journal-j_dev_file-f_mapping-host;
-   if (!S_ISBLK(jdev_inode-i_mode)) {
-   reiserfs_warning(super, journal_init_dev: '%s' is 
-not a block device, jdev_name);
-   result = -ENOTBLK;
-   release_journal_dev(super, journal);
-   } else {
-   /* ok */
-   journal-j_dev_bd = I_BDEV(jdev_inode);
-   set_blocksize(journal-j_dev_bd, super-s_blocksize);
-   reiserfs_info(super,
- journal_init_dev: journal device: %s\n,
- bdevname(journal-j_dev_bd, b));
-   }
-   } else {
-   result = PTR_ERR(journal-j_dev_file);
-   journal-j_dev_file = NULL;
+   journal-j_dev_bd = open_bdev_excl(jdev_name, 0, journal);
+   if (IS_ERR(journal-j_dev_bd)) {
+   result = PTR_ERR(journal-j_dev_bd);
+   journal-j_dev_bd = NULL;
reiserfs_warning(super,
 journal_init_dev: Cannot open '%s': %i,
 jdev_name, result);
+   return result;
}
-   return result;
+
+   set_blocksize(journal-j_dev_bd, super-s_blocksize);
+   reiserfs_info(super,
+ journal_init_dev: journal device: %s\n,
+ bdevname(journal-j_dev_bd, b));
+   return 0;
 }
 
 /**
Index: linux-2.6-xfs/include/linux/reiserfs_fs_sb.h
===
--- linux-2.6-xfs.orig/include/linux/reiserfs_fs_sb.h   2007-12-13 
19:06:58.0 +0100
+++ linux-2.6-xfs/include/linux/reiserfs_fs_sb.h2007-12-26 
15:13:22.0 +0100
@@ -177,7 +177,6 @@ struct reiserfs_journal {
struct reiserfs_journal_cnode *j_last;  /* newest journal block */
struct reiserfs_journal_cnode *j_first; /*  oldest journal block.  
start here for traverse */
 
-   struct file *j_dev_file;
struct block_device *j_dev_bd;
int j_1st_reserved_block;   /* first block on s_dev of reserved 
area journal */
 
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [0/4] DST: Distributed storage.

2007-12-04 Thread Christoph Hellwig
   * fixed bug with XFS metadata update (it can provide slab pages to the
  DST, so it is not allowed to transfer them using -sendpage())

xfs hasn't been doing that anymore for quite a while.  Block drivers
don't need hacks for it anymore, epsecially as it's not reliably
detectable.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] cramfs: Add mount option swapendian

2007-11-15 Thread Christoph Hellwig
On Thu, Nov 15, 2007 at 12:45:20PM -0800, Linus Torvalds wrote:
 Please don't do it this way.
 
 It would be *much* better to just standardize on one endianness, and be 
 done with it. That way there are no config options, no confusion, and the 
 code is smaller, simpler, and faster. Because nn unconditional byte swap 
 is generally faster than a conditional non-byte-swap!
 
 So can you please just make it little-endian? 
 
 There can't be that many big-endian machines that really care about old 
 cramfs images..

Actually there are as lots of initrd are cramfs.  This means you'd need
to update mkcramfs all big endian machines out there.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: cramfs in big endian

2007-11-10 Thread Christoph Hellwig
On Fri, Nov 09, 2007 at 05:03:01PM -0800, H. Peter Anvin wrote:
 Endian-independent code is slower than wrong-endian code, because of the 
 necessary conditionals.  Thus, you DO NOT WANT this(*).

I'd prefer not to have it either.  But a someone (pinhead) was smart
enough not to define an endianess for cramfs from the beginning we're
stuck with it.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: cramfs in big endian

2007-11-07 Thread Christoph Hellwig
On Wed, Nov 07, 2007 at 09:51:48PM +0100, Andi Drebes wrote:
 Hi!
 
  I would suggest you to use squashfs instead of cramfs.
  First, it's newer, it's better, it's actively developed, it doesn't have any
  limits like the bad cramfs. 
 I'm developing a new linux based firmware for my router which uses cramfs. 
 Switching to squashfs still needs some time. Meanwhile, I have to work with 
 cramfs. As the router uses the big endian format and as my machine works with 
 the little endian format, I'm unable to mount the router's filesystem images.

Making cramfs endianess-independent shouldn't be much work.  Take a look
at the helpers in fs/ufs/swab.h and use them for every ondisk access in
cramfs.  Drop me a not if you need some help.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Problem with accessing namespace_sem from LSM.

2007-11-07 Thread Christoph Hellwig
On Thu, Nov 08, 2007 at 07:04:23AM +0900, Tetsuo Handa wrote:
 The reason why I want to access namespace_sem inside security_inode_create() 
 is that
 it doesn't receive struct vfsmount parameter.
 If struct vfsmount *were* passed to security_inode_create(), 
 I have no need to access namespace_sem.

Same argument as with the AA folks: it does not have any business looking
at the vfsmount.  If you create a file it can and in many setups will
show up in multiple vfsmounts, so making decisions based on the particular
one this creat happens through is wrong and actually dangerous.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Problem with accessing namespace_sem from LSM.

2007-11-06 Thread Christoph Hellwig
On Tue, Nov 06, 2007 at 01:00:41PM +0900, Tetsuo Handa wrote:
 Hello.
 
 I found that accessing namespace_sem from security_inode_create()
 causes lockdep warning when compiled with CONFIG_PROVE_LOCKING=y .

Any code except VFS internals has no business using it at all and doesn't
do that in mainline either.  I'd start looking for design bugs in whatever
code you have using it first.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] VFS: apply coding standards to fs/ioctl.c

2007-10-30 Thread Christoph Hellwig
On Sun, Oct 28, 2007 at 02:05:16PM -0400, Erez Zadok wrote:
 
 Sure.  I assume you mean an internal function to encapsulate the entire case
 statement's code, one for each of the FIO* cases.

Yes.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] VFS: apply coding standards to fs/ioctl.c

2007-10-30 Thread Christoph Hellwig
On Sun, Oct 28, 2007 at 07:57:47PM -0700, Daniel Phillips wrote:
 On 10/28/07, Christoph Hellwig [EMAIL PROTECTED] wrote:
  While you're at it, it's probably worth splitting this out into
  a small helper function.
 
 Why? Is the same pattern called from more than one place?

Becauase it's a lot more readable.  ioctl subcommands are invidividual
functionality, and separating them out into small self-contained functions
makes the code a lot more readable.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] VFS: swap do_ioctl and vfs_ioctl names

2007-10-30 Thread Christoph Hellwig
On Sun, Oct 28, 2007 at 08:40:56PM -0400, Erez Zadok wrote:
 +/**
 + * vfs_ioctl - call filesystem specific ioctl methods
 + *
 + * @filp: [in] open file to invoke ioctl method on
 + * @cmd:  [in] ioctl command to execute
 + * @arg:  [in/out] command-specific argument for ioctl

I've never seen these in/out annotations and doubt they're valid in
kerneldoc.  Randy?

 + * Invokes filesystem specific -unlock_ioctl, if one exists; otherwise

unlocked_ioctl

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] VFS: factor out three helpers for FIBMAP/FIONBIO/FIOASYNC file ioctls

2007-10-30 Thread Christoph Hellwig
 +static int __ioctl_fibmap(struct file *filp, int __user *p)

I'd say kill the __ prefix for all the functions you're adding.

 +static int __ioctl_fionbio(struct file *filp, unsigned long arg)

 +static int __ioctl_fioasync(unsigned int fd, struct file *filp,
 + unsigned long arg)

For these two I'd add a

void __user *argp = (void __user *)arg;

in the caller and then just pass argp down.  That way we have the cast in
one place.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] VFS: factor out three helpers for FIBMAP/FIONBIO/FIOASYNC file ioctls

2007-10-30 Thread Christoph Hellwig
On Tue, Oct 30, 2007 at 01:49:48PM -0400, Erez Zadok wrote:
 BTW, what's the origin of this oddity in fs/ioctl.c:
 
 #ifdef __sparc__
   /* SunOS compatibility item. */
   if (O_NONBLOCK != O_NDELAY)
   flag |= O_NDELAY;
 #endif
 
 It seems rather odd to have architecture-specific code in the VFS, no?

When Dave did the sparc port he followed sunos ABIs for lots of things.
When these ABIs are hidden behind ioctl arguments they can't easily
be handled in arch code and we need warts like that.  It's definitively
not recommended for new ports..

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] VFS: apply coding standards to fs/ioctl.c

2007-10-28 Thread Christoph Hellwig
Nice, I always hated these double-indented switch statements.

 + case FIBMAP:
 + {
 + struct address_space *mapping = filp-f_mapping;
 + int res;
 + /* do we support this mess? */
 + if (!mapping-a_ops-bmap)
 + return -EINVAL;
 + if (!capable(CAP_SYS_RAWIO))
 + return -EPERM;
 + error = get_user(block, p);
 + if (error)
 + return error;
 + lock_kernel();
 + res = mapping-a_ops-bmap(mapping, block);
 + unlock_kernel();
 + return put_user(res, p);

While you're at it, it's probably worth splitting this out into
a small helper function.

 + case FIONBIO:
 + error = get_user(on, (int __user *)arg);
 + if (error)
 + break;
 + flag = O_NONBLOCK;
  #ifdef __sparc__
 + /* SunOS compatibility item. */
 + if (O_NONBLOCK != O_NDELAY)
 + flag |= O_NDELAY;
  #endif
 + if (on)
 + filp-f_flags |= flag;
 + else
 + filp-f_flags = ~flag;
 + break;

Same here.

 + case FIOASYNC:
 + error = get_user(on, (int __user *)arg);
 + if (error)
   break;
 + flag = on ? FASYNC : 0;
 +
 + /* Did FASYNC state change ? */
 + if ((flag ^ filp-f_flags)  FASYNC) {
 + if (filp-f_op  filp-f_op-fasync) {
 + lock_kernel();
 + error = filp-f_op-fasync(fd, filp, on);
 + unlock_kernel();
 + } else
   error = -ENOTTY;
 + }
 + if (error != 0)
   break;
 +
 + if (on)
 + filp-f_flags |= FASYNC;
 + else
 + filp-f_flags = ~FASYNC;
 + break;

And here.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] VFS: swap do_ioctl and vfs_ioctl names

2007-10-28 Thread Christoph Hellwig
On Sat, Oct 27, 2007 at 07:10:44PM -0400, Erez Zadok wrote:
 Rename old vfs_ioctl to do_ioctl, because the comment above it clearly
 indicates that it is an internal function not to be exported to modules;
 therefore it should have a more traditional do_XXX name.  The new do_ioctl
 is exported in fs.h but not to modules.
 
 Rename the old do_ioctl to vfs_ioctl because the names vfs_XXX should
 preferably be reserved to callable VFS functions which modules may call,
 as many other vfs_XXX functions already do.

Yes, good idea for consistency.

 Export the new vfs_ioctl to
 modules so others can use it (including Unionfs and eCryptfs).

 +EXPORT_SYMBOL(vfs_ioctl);

This should be an _GPL export.  All new exports for above VFS users
like NFSD or stackable filesystem are _GPL because they're not for
general consumptions but these rather specific tied to the kernel
uses.

And while you're at it I'd suggest adding a docbook comment describing
the new export vfs_ioctl because we'd eventually like to have the exported
API documented fully.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] Unionfs: security convert lsm into a static interface fix

2007-10-23 Thread Christoph Hellwig
On Mon, Oct 22, 2007 at 08:48:04PM -0400, Erez Zadok wrote:
 Why?  Are you concerned that the security policy may change after a module
 is loaded?

No, it's a matter of proper layering.  We generally don't want modules
like stackabke filesystems to call directly into methods but rather use
proper highlevel VFS helpers to isolate them from details and possible
changes.  The move to out of line security_ helpers just put this on the
radard.

 I can probably get rid of having unionfs call security_inode_permission, by
 calling permission() myself and carefully post-process its return code
 (unionfs needs to ignore EROFS initially, to allow copyup to take place).

Sounds fine.

 But security_file_ioctl doesn't have any existing helper I can call.  I can
 introduce a trivial vfs_security_file_ioctl wrapper to security_file_ioctl,
 but what about the already existing *19* exported security_* functions in
 security/security.c?  Do you want to see simple wrappers for all of them?
 It seems redundant to add a one-line wrapper around an already one-line
 function around security_ops-XXX.  Plus, some of the existing exported
 security_* functions are file-system related, others are networking, etc.  So
 we'll need wrappers whose names are prefixed appropriately: vfs_*, net_*,
 etc.

The fix for security_file_ioctl is probably to either not do it at all
or move it the call to security_file_ioctl into vfs_ioctl and get it by
using that helper.  I suspect most other security_ exports should be
avoided similarly.

I also suspect the whole issue of where and how-many times to call LSM
methods for stackable filesystems is a huge can of worms and it might make
sense to talk to the LSM folks about it.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 1/2] Case-insensitive XFS - kernel patch

2007-10-23 Thread Christoph Hellwig
This patch is quite badly mangled by your mailer.  Could you just
attach it?  (Or even better use a mailer that handles inlined text
without mangling it..)

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] Unionfs: security convert lsm into a static interface fix

2007-10-22 Thread Christoph Hellwig
On Sun, Oct 21, 2007 at 07:51:14PM -0400, Erez Zadok wrote:
 From: Andrew Morton [EMAIL PROTECTED]
 
 ERROR: security_inode_permission [fs/unionfs/unionfs.ko] undefined!
 ERROR: security_file_ioctl [fs/unionfs/unionfs.ko] undefined!
 
 Need these back.

These should never used by modules.  You'll need to use and/or introduce
vfs_ helpers that do proper security checks before calling the methods.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs

2007-10-17 Thread Christoph Hellwig
On Mon, Oct 15, 2007 at 02:31:03PM -0400, Jeff Mahoney wrote:
 Here's a patch I worked up the other night that kills off struct file
 completely from the xattr code. I've tested it locally.

Looks like a merge of Dave's and my patch :)

ACK from me, I don't care whether it's one or two patches.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 2.6.23-mm1: BUG in reiserfs_delete_xattrs

2007-10-15 Thread Christoph Hellwig
On Mon, Oct 15, 2007 at 12:34:58AM +0200, Laurent Riffard wrote:
 reiserfs_delete_xattrs
 reiserfs_delete_inode
 generic_delete_inode
 generic_drop_inode
 iput
 do_unlinkat
 sys_unlink
 sys_enter_past_esp
 
 I reported a similar BUG in 2.6.22-rc8-mm2 (see
 http://lkml.org/lkml/2007/9/27/235). Dave Hansen sent a patch for it, I
 tested it and it was OK for 2.6.22-rc8-mm2.
 
 I tried this patch on 2.6.23-mm1, and it fixed the BUGs here too.

The delete path is a similar case as the one Dave fixed, also cause by
a NULL vfsmount passed to dentry_open, but through a different code-path.

Untested fix for this problem below:

Index: linux-2.6.23-rc8/fs/reiserfs/xattr.c
===
--- linux-2.6.23-rc8.orig/fs/reiserfs/xattr.c   2007-09-30 14:13:46.0 
+0200
+++ linux-2.6.23-rc8/fs/reiserfs/xattr.c2007-09-30 14:18:30.0 
+0200
@@ -207,9 +207,8 @@ static struct dentry *get_xa_file_dentry
  * we're called with i_mutex held, so there are no worries about the directory
  * changing underneath us.
  */
-static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
+static int __xattr_readdir(struct inode *inode, void *dirent, filldir_t 
filldir)
 {
-   struct inode *inode = filp-f_path.dentry-d_inode;
struct cpu_key pos_key; /* key of current position in the directory 
(key of directory entry) */
INITIALIZE_PATH(path_to_entry);
struct buffer_head *bh;
@@ -352,24 +351,19 @@ static int __xattr_readdir(struct file *
  * this is stolen from vfs_readdir
  *
  */
-static
-int xattr_readdir(struct file *file, filldir_t filler, void *buf)
+static int xattr_readdir(struct inode *inode, filldir_t filler, void *buf)
 {
-   struct inode *inode = file-f_path.dentry-d_inode;
int res = -ENOTDIR;
-   if (!file-f_op || !file-f_op-readdir)
-   goto out;
+
mutex_lock_nested(inode-i_mutex, I_MUTEX_XATTR);
-//down(inode-i_zombie);
res = -ENOENT;
if (!IS_DEADDIR(inode)) {
lock_kernel();
-   res = __xattr_readdir(file, buf, filler);
+   res = __xattr_readdir(inode, buf, filler);
unlock_kernel();
}
-//up(inode-i_zombie);
mutex_unlock(inode-i_mutex);
-  out:
+
return res;
 }
 
@@ -721,7 +715,6 @@ reiserfs_delete_xattrs_filler(void *buf,
 /* This is called w/ inode-i_mutex downed */
 int reiserfs_delete_xattrs(struct inode *inode)
 {
-   struct file *fp;
struct dentry *dir, *root;
int err = 0;
 
@@ -742,15 +735,8 @@ int reiserfs_delete_xattrs(struct inode 
return 0;
}
 
-   fp = dentry_open(dir, NULL, O_RDWR);
-   if (IS_ERR(fp)) {
-   err = PTR_ERR(fp);
-   /* dentry_open dputs the dentry if it fails */
-   goto out;
-   }
-
lock_kernel();
-   err = xattr_readdir(fp, reiserfs_delete_xattrs_filler, dir);
+   err = xattr_readdir(dir-d_inode, reiserfs_delete_xattrs_filler, dir);
if (err) {
unlock_kernel();
goto out_dir;
@@ -770,7 +756,7 @@ int reiserfs_delete_xattrs(struct inode 
unlock_kernel();
 
   out_dir:
-   fput(fp);
+   dput(dir);
 
   out:
if (!err)
@@ -812,7 +798,6 @@ reiserfs_chown_xattrs_filler(void *buf, 
 
 int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
 {
-   struct file *fp;
struct dentry *dir;
int err = 0;
struct reiserfs_chown_buf buf;
@@ -836,13 +821,6 @@ int reiserfs_chown_xattrs(struct inode *
goto out;
}
 
-   fp = dentry_open(dir, NULL, O_RDWR);
-   if (IS_ERR(fp)) {
-   err = PTR_ERR(fp);
-   /* dentry_open dputs the dentry if it fails */
-   goto out;
-   }
-
lock_kernel();
 
attrs-ia_valid = (ATTR_UID | ATTR_GID | ATTR_CTIME);
@@ -850,7 +828,7 @@ int reiserfs_chown_xattrs(struct inode *
buf.attrs = attrs;
buf.inode = inode;
 
-   err = xattr_readdir(fp, reiserfs_chown_xattrs_filler, buf);
+   err = xattr_readdir(dir-d_inode, reiserfs_chown_xattrs_filler, buf);
if (err) {
unlock_kernel();
goto out_dir;
@@ -860,7 +838,7 @@ int reiserfs_chown_xattrs(struct inode *
unlock_kernel();
 
   out_dir:
-   fput(fp);
+   dput(dir);
 
   out:
attrs-ia_valid = ia_valid;
@@ -1008,7 +986,6 @@ reiserfs_listxattr_filler(void *buf, con
  */
 ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
 {
-   struct file *fp;
struct dentry *dir;
int err = 0;
struct reiserfs_listxattr_buf buf;
@@ -1031,13 +1008,6 @@ ssize_t reiserfs_listxattr(struct dentry
goto out;
}
 
-   fp = dentry_open(dir, NULL, O_RDWR);
-   if (IS_ERR(fp)) {
-   err = PTR_ERR(fp);
-   /* 

Re: [PATCH 03/32] IGET: Introduce a function to register iget failure [try #2]

2007-10-05 Thread Christoph Hellwig
On Thu, Oct 04, 2007 at 04:56:17PM +0100, David Howells wrote:
 Introduce a function to register failure in an inode construction path.  This
 includes marking the inode under construction as bad, unlocking it and
 releasing it.

I'm a bit unconfortable with the name, but except for that this function
and the users added in the next patches look fine.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/32] IGET: Mark iget() and read_inode() as being obsolete [try #2]

2007-10-05 Thread Christoph Hellwig
Why do you move it out of line?
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. [try #2]

2007-10-05 Thread Christoph Hellwig
On Thu, Oct 04, 2007 at 04:56:07PM +0100, David Howells wrote:
 Add an ERR_CAST() macro to complement ERR_PTR and co. for the purposes of
 casting an error entyped as one pointer type to an error of another pointer
 type whilst making it explicit as to what is going on.
 
 This provides a replacement for the ERR_PTR(PTR_ERR(p)) construct.

I don't like this one very much, I'd rather take the variant Linus
outline in his last post on that topic..

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RFC: Case-insensitive support for XFS

2007-10-05 Thread Christoph Hellwig
[Adding -fsdevel because some of the things touched here might be of
 broader interest and Urban because his name is on nls_utf8.c]

On Fri, Oct 05, 2007 at 11:57:54AM +1000, Barry Naujok wrote:
 
 On it's own, linux only provides case conversion for old-style
 character sets - 8 bit sequences only. A lot of distos are
 now defaulting to UTF-8 and Linux NLS stuff does not support
 case conversion for any unicode sets.

The lack of case tables in nls_utf8.c defintively seems odd to me.
Urban, is there a reason for that?  The only thing that comes to
mind is that these tables might be quite large.

 NTFS in Linux also implements it's own dcache and NTFS also

^^^ dentry operations?

 stores its unicode case table on disk. This allows the filesystem
 to migrate to newer forms of Unicode at the time of formatting
 the filesystem. Eg. Windows Vista now supports Unicode 5.0
 while older version would support an earlier version of
 Unicode. Linux's version of NTFS case table is implemented
 in fs/ntfs/upcase.c defined as default_upcase.

Because ntfs uses 16bit wide chars it prefers to use it's own tables.
I'm not sure it's a that good idea.  JFS also has wide-char names on
disk but at least partially uses the generic nls support, so there must
be some trade-offs.

 It will be proposed that in the future, XFS may default to
 UTF-8 on disk and to go for the old format, explicitily
 use a mkfs.xfs option. Two superbits will be used: one for
 case-insensitive (which generates lowercase hashes on disk)
 and that already exists on IRIX filesystems and a new one
 for UTF-8 filenames. Any combination of the two bits can be
 used and the dentry_operations will be adjusted accordingly.

I don't think arbitrary combinations make sense.  Without case insensitive
support a unix filesystem couldn't care less what charset the filenames
are in, except for the terminating 0 and '/', '.', '..' it's an entirely
opaqueue stream of bytes.  So chosing a charset only makes sense
with the case insensitive filename option.

 So, in regards to the UTF-8 case-conversion/folding table, we
 have several options to choose from:
- Use the HFS+ method as-is.
- Use an NTFS scheme with an on-disk table.
- Pick a current table and stick with it (similar to HFS+).
- How much of Unicode to we support? Just the the Basic
  Multilingual Plane (U+ - U+) or the entire set?
  (anything above U+ won't have case-conversion
   requirements). Seems that all the other filesystems
   just support the BMP.
- UTF-8, UTF-16 or UCS-2.
 
 With the last point, UTF-8 has several advantages IMO:
- xfs_repair can easily detect UTF-8 sequences in filenames
  and also validate UTF-8 sequences.
- char based structures don't change
- nulls in filenames.
- no endian conversions required.

I think the right approach is to use the fs/nls/ code and allow the
user to select any table with a mount option as at least in russia
and eastern europe some non-utf8 charsets still seem to be prefered.
The default should of course be utf8 and support for utf8 case
conversion should be added to fs/nls/

 Internally, the names will probably be converted to u16s for
 efficient processing. Conversion between UTF-8 and UTF-16/UCS-2
 is very straight forward.

Do we really need that?  And if so please make sure this only happens
for filesystems created with the case insensitivity option so normal
filesystems don't have to pay for these bloated strings.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/30] IGET: Stop BEFS from using iget() and read_inode()

2007-10-01 Thread Christoph Hellwig
On Mon, Oct 01, 2007 at 10:44:59AM -0700, Linus Torvalds wrote:
  If you're soliciting opinions, I think I tend to prefer the feel of the
  code paths after the changes.  I don't know the benefits of the change
  are worth the risk in unmaintained file systems, though.
  
   + return ERR_PTR(PTR_ERR(inode));
  
  This caught my eye.  Surely we can do better :).  It seems to happen a
  few times in the patches, the instance in this patch was the first that
  I noticed.
 
 Yeah. The above obviously *should* be the same as
 
   return inode;
 
 apart from a few casts. But if the casts matter, there's something else 
 wrong.

befs_lookup, which the above gem is from, returns a dentry *.

And given either

return (dentry *)inode;

or
return ERR_PTR(PTR_ERR(inode));

I tend to prefer the latter.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Upgrading datastructures between different filesystem versions

2007-09-29 Thread Christoph Hellwig
On Fri, Sep 28, 2007 at 03:47:24PM -0400, Theodore Tso wrote:
 Ext3 does something similar, zapping space at the beginning AND the
 end of the partition (because the MD superblocks are at the end).
 It's just a misfeature of reiserfs's mkfs that it doesn't do this.

mkfs.xfs of course also whipes at the end.  I just wanted to show how
easy this is to fix.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] make reiserfs stop using 'struct file' for internal xattr operations

2007-09-28 Thread Christoph Hellwig
On Thu, Sep 27, 2007 at 02:51:25PM -0700, Andrew Morton wrote:
 That'll be because reiserfs-convert-to-new-aops.patch witched reiserfs over
 to -write_begin() and -write_end().

Yeah, I was looking at mainline.

 So your stuff becomes dependent on Nick's stuff, and Nick's stuff is still
 failing on NFS, I think.

I'd rather avoid the paramater removal for now, that makes it less
entangle, and it's an unrelated cleanup anyway.

Btw, there's more abuse of this sort in reiserfs.  Various other places
in xattr.c call dentry_open directly without the vfsmount aswell.  And
handling of an external journal uses filp_open which is similarly stupid,
it should use open_bdev_excl like xfs or the generic code to open the
main filesystem blockdevice.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH] stop abusing filp_open in reiserfs journal code

2007-09-28 Thread Christoph Hellwig
And here's a patch to stop the filp abuse in the journal code.  An additional
benefit is that the block device is now properly claimed when opened by
device number.


Index: linux-2.6/fs/reiserfs/journal.c
===
--- linux-2.6.orig/fs/reiserfs/journal.c2007-09-28 09:18:50.0 
+0200
+++ linux-2.6/fs/reiserfs/journal.c 2007-09-28 09:28:36.0 +0200
@@ -2544,11 +2544,9 @@ static int release_journal_dev(struct su
 
result = 0;
 
-   if (journal-j_dev_file != NULL) {
-   result = filp_close(journal-j_dev_file, NULL);
-   journal-j_dev_file = NULL;
-   journal-j_dev_bd = NULL;
-   } else if (journal-j_dev_bd != NULL) {
+   if (journal-j_dev_bd != NULL) {
+   if (journal-j_dev_bd-bd_dev != super-s_dev)
+   bd_release(journal-j_dev_bd);
result = blkdev_put(journal-j_dev_bd);
journal-j_dev_bd = NULL;
}
@@ -2573,7 +2571,6 @@ static int journal_init_dev(struct super
result = 0;
 
journal-j_dev_bd = NULL;
-   journal-j_dev_file = NULL;
jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super-s_dev;
 
@@ -2590,35 +2587,34 @@ static int journal_init_dev(struct super
 cannot init journal device '%s': %i,
 __bdevname(jdev, b), result);
return result;
-   } else if (jdev != super-s_dev)
+   } else if (jdev != super-s_dev) {
+   result = bd_claim(journal-j_dev_bd, journal);
+   if (result) {
+   blkdev_put(journal-j_dev_bd);
+   return result;
+   }
+
set_blocksize(journal-j_dev_bd, super-s_blocksize);
+   }
+
return 0;
}
 
-   journal-j_dev_file = filp_open(jdev_name, 0, 0);
-   if (!IS_ERR(journal-j_dev_file)) {
-   struct inode *jdev_inode = journal-j_dev_file-f_mapping-host;
-   if (!S_ISBLK(jdev_inode-i_mode)) {
-   reiserfs_warning(super, journal_init_dev: '%s' is 
-not a block device, jdev_name);
-   result = -ENOTBLK;
-   release_journal_dev(super, journal);
-   } else {
-   /* ok */
-   journal-j_dev_bd = I_BDEV(jdev_inode);
-   set_blocksize(journal-j_dev_bd, super-s_blocksize);
-   reiserfs_info(super,
- journal_init_dev: journal device: %s\n,
- bdevname(journal-j_dev_bd, b));
-   }
-   } else {
-   result = PTR_ERR(journal-j_dev_file);
-   journal-j_dev_file = NULL;
+   journal-j_dev_bd = open_bdev_excl(jdev_name, 0, journal);
+   if (IS_ERR(journal-j_dev_bd)) {
+   result = PTR_ERR(journal-j_dev_bd);
+   journal-j_dev_bd = NULL;
reiserfs_warning(super,
 journal_init_dev: Cannot open '%s': %i,
 jdev_name, result);
+   return result;
}
-   return result;
+
+   set_blocksize(journal-j_dev_bd, super-s_blocksize);
+   reiserfs_info(super,
+ journal_init_dev: journal device: %s\n,
+ bdevname(journal-j_dev_bd, b));
+   return 0;
 }
 
 /*
Index: linux-2.6/include/linux/reiserfs_fs_sb.h
===
--- linux-2.6.orig/include/linux/reiserfs_fs_sb.h   2007-09-28 
09:24:27.0 +0200
+++ linux-2.6/include/linux/reiserfs_fs_sb.h2007-09-28 09:24:31.0 
+0200
@@ -177,7 +177,6 @@ struct reiserfs_journal {
struct reiserfs_journal_cnode *j_last;  /* newest journal block */
struct reiserfs_journal_cnode *j_first; /*  oldest journal block.  
start here for traverse */
 
-   struct file *j_dev_file;
struct block_device *j_dev_bd;
int j_1st_reserved_block;   /* first block on s_dev of reserved 
area journal */
 


-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Upgrading datastructures between different filesystem versions

2007-09-28 Thread Christoph Hellwig
On Fri, Sep 28, 2007 at 03:11:00PM +0200, Erik Mouw wrote:
 There are however ways to confuse it: if you reformat an ext3
 filesystem to reiserfs (version 3), mounting that filesystem without
 -t reiserfs will trick mount(8) into mounting it as an ext3
 filesystem (which will usually fail). This is because the ext3
 superblocks lives at offset 0x400, and the reiserfs superblock at
 0x8000. When you format a partition as reiserfs, it will not erase old
 ext3 superblocks. Before looking for a reiserfs superblock, mount(8)
 first looks for an ext3 superblock. The old ext3 superblock wasn't
 erased, but usually most of the other ext3 structures are and so
 mount(8) will fail to mount the filesystem. Don't know if this
 particular bug is still there, but it has bitten me in the past.

This is easy to fix, though.  Quoting mkfs.xfs:

/*
 * Zero out the beginning of the device, to obliterate any old
 * filesystem signatures out there.  This should take care of
 * swap (somewhere around the page size), jfs (32k),
 * ext[2,3] and reiserfs (64k) - and hopefully all else.
 */
buf = libxfs_getbuf(xi.ddev, 0, BTOBB(WHACK_SIZE));
bzero(XFS_BUF_PTR(buf), WHACK_SIZE);
libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
libxfs_purgebuf(buf);
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 2.6.23-rc8-mm2: BUG near reiserfs_xattr_set

2007-09-27 Thread Christoph Hellwig
On Thu, Sep 27, 2007 at 12:48:33PM -0700, Andrew Morton wrote:
   __fput+0x124/0x1a9
   fput+0x31/0x35
   reiserfs_xattr_set+0x291/0x2b0 [reiserfs]
   user_set+0x4c/0x57 [reiserfs]
   reiserfs_setxattr+0x81/0xf1 [reiserfs]
   vfs_setxattr+0x7d/0xfa
   setxattr+0xb9/0xd1
   sys_lsetxattr+0x4c/0x85
   sysenter_past_esp+0x57/0x85
  
  EIP: mnt_drop_write+0x5b/0x9d
  
 
 Hi, Dave!

This sure looks like a result of the reiserfs xattr code beeing
really sucky and passing a NULL vfsmount to dentry_open.

Dave will probably find a bandaid to work around this, but the
right fix is to stop using a file struct here entirely.  If you
look at reiserfs_xattr_set it's not actually used at all except
for passing it to -prepare_write and -commit_write which then
don't use it at all.  All that crap should be rewritten to just
pass the dentry around.  Note that all this should not acquire
writer counts on the vfsmount - we have done this already
before calling into the xattr methods.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH] make reiserfs stop using 'struct file' for internal xattr operations

2007-09-27 Thread Christoph Hellwig
On Thu, Sep 27, 2007 at 01:53:39PM -0700, Dave Hansen wrote:
 -int reiserfs_commit_write(struct file *f, struct page *page,
 -   unsigned from, unsigned to);
 -int reiserfs_prepare_write(struct file *f, struct page *page,
 -unsigned from, unsigned to);
 +int reiserfs_commit_write(struct page *page, unsigned from, unsigned to);
 +int reiserfs_prepare_write(struct page *page, unsigned from, unsigned to);

I doubt this will work.  These are also used for the -prepare_write
and -commit_write aops, and the method signature definitively wants
a file there, even if it's zero..

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/25] Unionfs: cast page-index loff_t before shifting

2007-09-26 Thread Christoph Hellwig
On Tue, Sep 25, 2007 at 11:09:44PM -0400, Erez Zadok wrote:
 Fixes bugs in number promotion/demotion computation, as per
 http://lkml.org/lkml/2007/9/20/17

It's better to use te page_offset helper as that avoids any confusion
on where to cast.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 2/2] VFS: allow filesystem to override mknod capability checks

2007-09-24 Thread Christoph Hellwig
On Mon, Sep 24, 2007 at 02:25:54PM +0200, Miklos Szeredi wrote:
 From: Miklos Szeredi [EMAIL PROTECTED]
 
 Add a new super block flag, that results in the VFS not checking if
 the current process has enough privileges to do an mknod().
 
 If this flag is set, all mounts for this super block will have the
 nodev flag implied.
 
 This is needed on filesystems, where an unprivileged user may be able
 to create a device node, without causing security problems.
 
 One such example is mountlo a loopback mount utility implemented
 with fuse and UML, which runs as an unprivileged userspace process.
 In this case the user does in fact have the right to create device
 nodes within the filesystem image, as long as the user has write
 access to the image.  Since the filesystem is mounted with nodev,
 adding device nodes is not a security concern.

This one looks okay, but I'd prefer to not put it in until we actually
have proper non-privilegued mounts.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 1/2] VFS: new fgetattr() file operation

2007-09-24 Thread Christoph Hellwig
On Mon, Sep 24, 2007 at 03:18:10PM +0200, Miklos Szeredi wrote:
  Or not support such a broken protocol at all.
 
 Wonder what people would say if we removed support for NFSv[23].
 
 Just because a protocol does not support perfect UNIX semantics, it
 doesn't mean it's broken.  By that standard almost all network
 filesystem protocols are severely broken.

Well, they are broken by these and other standards.  At least nfs and
cifs maintainers do the workarounds for this brokeness where they belong.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/18] exportfs: add new methods

2007-09-21 Thread Christoph Hellwig
On Thu, Sep 20, 2007 at 05:18:40PM -0700, Andrew Morton wrote:
 On Wed, 19 Sep 2007 18:30:25 +0200
 Christoph Hellwig [EMAIL PROTECTED] wrote:
 
  +   /*
  +* It's not a directory.  Life is a little more complicated.
  +*/
  +   struct dentry *target_dir, *nresult;
  +   char nbuf[NAME_MAX+1];
 
 Lots of stack usage there.

True.  But this is just copying the old code around to make use of the
new methods, so I didn't want to mess with underlying details.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 3/5] VFS: pass open file to -xattr()

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 02:23:46PM +0200, Miklos Szeredi wrote:
 From: Miklos Szeredi [EMAIL PROTECTED]
 
 Pass the open file into the filesystem's *xattr() methods.
 
 This is needed to be able to correctly implement open-unlink-f*xattr
 semantics, without having to resort to silly-renaming.
 
 Do this by adding a 'struct file *' parameter to i_op-*xattr().  For
 f... variants 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.

NACK, no more optional arguments, and passing file structs to xattr
stuff is silly.  If your filesystem doesn't get open but unliked
right you will have to resort to silly renaming, I'm sorry.

Same argument applies to all pass file down patches in the series,
I won't comment on the separately.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 4/5] VFS: allow filesystems to implement atomic open+truncate

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 02:23:47PM +0200, Miklos Szeredi wrote:
 From: Miklos Szeredi [EMAIL PROTECTED]
 
 Add a new attribute flag ATTR_OPEN, with the meaning: truncation was
 initiated by open() due to the O_TRUNC flag.
 
 This way filesystems wanting to implement truncation within their
 -open() method can ignore such truncate requests.
 
 This is a quick  dirty hack, but it comes for free.

Fine with me as it doesn't cause any active harm, but expect this to
go away once the nfs intent mess is cleaned up and we'll get a real
method for this kind of thing.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 5/5] VFS: allow filesystem to override mknod capability checks

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 02:23:48PM +0200, Miklos Szeredi wrote:
 From: Miklos Szeredi [EMAIL PROTECTED]
 
 Add a new filesystem flag, that results in the VFS not checking if the
 current process has enough privileges to do an mknod().
 
 This is needed on filesystems, where an unprivileged user may be able
 to create a device node, without causing security problems.

A user should never be able to create devices.  And no, I don't want to
see a filesystem that implements it's own file operations for device nodes.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 5/5] VFS: allow filesystem to override mknod capability checks

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 03:10:26PM +0200, Miklos Szeredi wrote:
 Take this example: I've loopback mounted an UML disk image using fuse
 (no privileges required), and want to create some device nodes.  I
 can't yet boot the UML because the device node is missing from the
 image.  So what should I do.  Currently I have to manipulate the
 mounted image as root.  But that's really shouldn't be needed.

That's something that shouldn't be solved in the filesystem, but rather
through exact semantics of unprivilegued mounts.  Given that an
unprivilegued implies ignoring the device files we can easily allow
users to create them, because they're nothing special anymore.

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 3/5] VFS: pass open file to -xattr()

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 03:00:06PM +0200, Miklos Szeredi wrote:
 I don't think it's silly.  Read/write get passed the file descriptor,
 and it makes a lot of sense, if the filesystem has stateful opens.
 
 Similarly for any fs operation that gets a file descriptor, it makes
 sense to pass the relevant open file down into the filesystem.

read/write fundamentally operate on file descriptors.  None of these
operations does, rather their normal forms get a path name and special
forms operate on a file descriptor to avoid lookup races.  Still the
underlying operation has nothing to do with the file descriptor at all.

 If you look carefully, the ftrunacate() already does this, becuse
 without that it's impossible to implement correct semantics in the
 filesystem in some cases.

ftruncate is a special case due to O_TRUNC.  But I have plans to solve
this whole issue more elegant than the current hack.

 For other operations it's not impossible, but it would mean more hacks
 in the filesystem itself (such as sillyrenaming) that are entirely
 unneeded if the file info is available.

It's not a problem at all for filesystem that implement normal unix
semantics.  If you want to shoer-horn strange semantics that barely
fit, you'll need some more hacks.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 5/5] VFS: allow filesystem to override mknod capability checks

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 03:18:33PM +0200, Miklos Szeredi wrote:
  That's something that shouldn't be solved in the filesystem, but rather
  through exact semantics of unprivilegued mounts.  Given that an
  unprivilegued implies ignoring the device files we can easily allow
  users to create them, because they're nothing special anymore.
 
 Exacly.  And we already have an API for that: mknod(2).  It would be
 quite stupid to introduce _another_ API to do the same.  It would mean
 that all the tools, like mknod(8) would not work with the new API.
 
 Or am I misunderstanding your suggestion?

Yes :)

My suggestions is:

 - mknod for unprivilegued user is allowed in the following case

(1) mount point is mounted with MNT_NODEV
(2) mount point is owner by the user doing mknod

 - and maybe

(3) we have a special mount option to allow it if we don't want
to allow it for normal unprivilegued mounts for some reason

which implies we need to get in unprivilegued mounts first, but we'll
have to do that anyway.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 3/5] VFS: pass open file to -xattr()

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 10:32:31AM -0400, Trond Myklebust wrote:
 On Fri, 2007-09-21 at 15:16 +0200, Miklos Szeredi wrote:
 
   ftruncate is a special case due to O_TRUNC.
  
  No, it's special, because it does not do permission checking, while
  truncate() does.
 
 So why not just add file-f_op-ftruncate() and file-f_op-fstat()?
 Most filesystems can trivially redirect these to do_truncate() and their
 existing getattr() method. Those, like FUSE, that care can use the hook.
 In fact, I think that NFSv4 could also benefit from an ftruncate():
 currently we have to hunt around for an open file context for that
 particular case.

Havin the file for fruncate is fine and I'm planning to do something
along those lines.  Having it for (f)stat is dumb because the operation
is in no way related to the open file descriptor.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 5/5] VFS: allow filesystem to override mknod capability checks

2007-09-21 Thread Christoph Hellwig
On Fri, Sep 21, 2007 at 04:48:58PM +0200, Miklos Szeredi wrote:
 Ah, OK.  Well, that's what fuse would do with the above change.  So
 you are basically saying, the change is OK, but we want proper
 unprivileged mounts first.

Yes, that and that it should be a mount flag, not a file_system_type
flag.

 I'm sure we don't want it by default.
 
 For example if user bind mounts / onto /home/user/myroot (with 'nodev'
 of couse), we still don't want mknod to work on that mount, for
 obvious reasons.

True, we'll have to deny it if there is any non-privilegued mount of
the backing device possible.   At this point it's getting rather nasty
and I wonder whether it's really worth it..
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/18] export operations rewrite

2007-09-19 Thread Christoph Hellwig
This patchset is a medium scale rewrite of the export operations
interface.  The goal is to make the interface less complex, and
easier to understand from the filesystem side, aswell as preparing
generic support for exporting of 64bit inode numbers.

This touches all nfs exporting filesystems, and I've done testing
on all of the filesystems I have here locally (xfs, ext2, ext3, reiserfs,   
jfs)

Unlike the last posting this series is against -mm (2.6.23-rc6-mm1
specificly), so the first patch has been dropped as it's in git-xfs
already, and the XFS conversion has gotten some major context changes
due to the changes in git-xfs.  Except for those and some typo fixes
in the documentation patch it's identical to the previous one.

This series is sent for inclusion into -mm.
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/18] exportfs: add fid type

2007-09-19 Thread Christoph Hellwig
Add a structured fid type so that we don't have to pass an array
of u32 values around everywhere.  It's a union of possible layouts.

As a start there's only the u32 array and the traditional 32bit
inode format, but there will be more in one of my next patchset
when I start to document the various filehandle formats we have
in lowlevel filesystems better.

Also add an enum that gives the various filehandle types human-
readable names.

Note:  Some people might think the struct containing an anonymous
union is ugly, but I didn't want to pass around a raw union type.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/include/linux/exportfs.h
===
--- linux-2.6.orig/include/linux/exportfs.h 2007-09-13 15:10:59.0 
+0200
+++ linux-2.6/include/linux/exportfs.h  2007-09-13 15:11:11.0 +0200
@@ -7,6 +7,44 @@ struct dentry;
 struct super_block;
 struct vfsmount;
 
+/*
+ * The fileid_type identifies how the file within the filesystem is encoded.
+ * In theory this is freely set and parsed by the filesystem, but we try to
+ * stick to conventions so we can share some generic code and don't confuse
+ * sniffers like ethereal/wireshark.
+ *
+ * The filesystem must not use the value '0' or '0xff'.
+ */
+enum fid_type {
+   /*
+* The root, or export point, of the filesystem.
+* (Never actually passed down to the filesystem.
+*/
+   FILEID_ROOT = 0,
+
+   /*
+* 32bit inode number, 32 bit generation number.
+*/
+   FILEID_INO32_GEN = 1,
+
+   /*
+* 32bit inode number, 32 bit generation number,
+* 32 bit parent directory inode number.
+*/
+   FILEID_INO32_GEN_PARENT = 2,
+};
+
+struct fid {
+   union {
+   struct {
+   u32 ino;
+   u32 gen;
+   u32 parent_ino;
+   u32 parent_gen;
+   } i32;
+   __u32 raw[6];
+   };
+};
 
 /**
  * struct export_operations - for nfsd to communicate with file systems
@@ -117,9 +155,9 @@ extern struct dentry *find_exported_dent
void *parent, int (*acceptable)(void *context, struct dentry *de),
void *context);
 
-extern int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
-   int connectable);
-extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh,
+extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
+   int *max_len, int connectable);
+extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
void *context);
 
Index: linux-2.6/fs/nfsd/nfsfh.c
===
--- linux-2.6.orig/fs/nfsd/nfsfh.c  2007-09-13 15:10:59.0 +0200
+++ linux-2.6/fs/nfsd/nfsfh.c   2007-09-13 15:13:32.0 +0200
@@ -115,8 +115,7 @@ fh_verify(struct svc_rqst *rqstp, struct
dprintk(nfsd: fh_verify(%s)\n, SVCFH_fmt(fhp));
 
if (!fhp-fh_dentry) {
-   __u32 *datap=NULL;
-   __u32 tfh[3];   /* filehandle fragment for oldstyle 
filehandles */
+   struct fid *fid = NULL, sfid;
int fileid_type;
int data_left = fh-fh_size/4;
 
@@ -128,7 +127,6 @@ fh_verify(struct svc_rqst *rqstp, struct
 
if (fh-fh_version == 1) {
int len;
-   datap = fh-fh_auth;
if (--data_left0) goto out;
switch (fh-fh_auth_type) {
case 0: break;
@@ -144,9 +142,11 @@ fh_verify(struct svc_rqst *rqstp, struct
fh-fh_fsid[1] = fh-fh_fsid[2];
}
if ((data_left -= len)0) goto out;
-   exp = rqst_exp_find(rqstp, fh-fh_fsid_type, datap);
-   datap += len;
+   exp = rqst_exp_find(rqstp, fh-fh_fsid_type,
+   fh-fh_auth);
+   fid = (struct fid *)(fh-fh_auth + len);
} else {
+   __u32 tfh[2];
dev_t xdev;
ino_t xino;
if (fh-fh_size != NFS_FHSIZE)
@@ -190,22 +190,22 @@ fh_verify(struct svc_rqst *rqstp, struct
error = nfserr_badhandle;
 
if (fh-fh_version != 1) {
-   tfh[0] = fh-ofh_ino;
-   tfh[1] = fh-ofh_generation;
-   tfh[2] = fh-ofh_dirino;
-   datap = tfh;
+   sfid.i32.ino = fh-ofh_ino;
+   sfid.i32.gen = fh-ofh_generation;
+   sfid.i32.parent_ino = fh-ofh_dirino;
+   fid = sfid

[PATCH 03/18] ext2: new export ops

2007-09-19 Thread Christoph Hellwig
Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/ext2/super.c
===
--- linux-2.6.orig/fs/ext2/super.c  2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/ext2/super.c   2007-09-13 15:16:25.0 +0200
@@ -248,13 +248,10 @@ static const struct super_operations ext
 #endif
 };
 
-static struct dentry *ext2_get_dentry(struct super_block *sb, void *vobjp)
+static struct inode *ext2_nfs_get_inode(struct super_block *sb,
+   u64 ino, u32 generation)
 {
-   __u32 *objp = vobjp;
-   unsigned long ino = objp[0];
-   __u32 generation = objp[1];
struct inode *inode;
-   struct dentry *result;
 
if (ino  EXT2_FIRST_INO(sb)  ino != EXT2_ROOT_INO)
return ERR_PTR(-ESTALE);
@@ -275,15 +272,21 @@ static struct dentry *ext2_get_dentry(st
iput(inode);
return ERR_PTR(-ESTALE);
}
-   /* now to find a dentry.
-* If possible, get a well-connected one
-*/
-   result = d_alloc_anon(inode);
-   if (!result) {
-   iput(inode);
-   return ERR_PTR(-ENOMEM);
-   }
-   return result;
+   return inode;
+}
+
+static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+   ext2_nfs_get_inode);
+}
+
+static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+   ext2_nfs_get_inode);
 }
 
 /* Yes, most of these are left as NULL!!
@@ -292,8 +295,9 @@ static struct dentry *ext2_get_dentry(st
  * Currently only get_parent is required.
  */
 static struct export_operations ext2_export_ops = {
+   .fh_to_dentry = ext2_fh_to_dentry,
+   .fh_to_parent = ext2_fh_to_parent,
.get_parent = ext2_get_parent,
-   .get_dentry = ext2_get_dentry,
 };
 
 static unsigned long get_sb_block(void **data)

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/18] ext3: new export ops

2007-09-19 Thread Christoph Hellwig
Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/ext3/super.c
===
--- linux-2.6.orig/fs/ext3/super.c  2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/ext3/super.c   2007-09-13 15:16:57.0 +0200
@@ -562,13 +562,10 @@ static int ext3_show_options(struct seq_
 }
 
 
-static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp)
+static struct inode *ext3_nfs_get_inode(struct super_block *sb,
+   u64 ino, u32 generation)
 {
-   __u32 *objp = vobjp;
-   unsigned long ino = objp[0];
-   __u32 generation = objp[1];
struct inode *inode;
-   struct dentry *result;
 
if (ino  EXT3_FIRST_INO(sb)  ino != EXT3_ROOT_INO)
return ERR_PTR(-ESTALE);
@@ -591,15 +588,22 @@ static struct dentry *ext3_get_dentry(st
iput(inode);
return ERR_PTR(-ESTALE);
}
-   /* now to find a dentry.
-* If possible, get a well-connected one
-*/
-   result = d_alloc_anon(inode);
-   if (!result) {
-   iput(inode);
-   return ERR_PTR(-ENOMEM);
-   }
-   return result;
+
+   return inode;
+}
+
+static struct dentry *ext3_fh_to_dentry(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+   ext3_nfs_get_inode);
+}
+
+static struct dentry *ext3_fh_to_parent(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+   ext3_nfs_get_inode);
 }
 
 #ifdef CONFIG_QUOTA
@@ -669,8 +673,9 @@ static const struct super_operations ext
 };
 
 static struct export_operations ext3_export_ops = {
+   .fh_to_dentry = ext3_fh_to_dentry,
+   .fh_to_parent = ext3_fh_to_parent,
.get_parent = ext3_get_parent,
-   .get_dentry = ext3_get_dentry,
 };
 
 enum {

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/18] exportfs: add new methods

2007-09-19 Thread Christoph Hellwig
Add the guts for the new filesystem API to exportfs.

There's now a fh_to_dentry method that returns a dentry for the 
object looked for given a filehandle fragment, and a fh_to_parent
operation that returns the dentry for the encoded parent directory
in case the file handle contains it.

There are default implementations for these methods that only take
a callback for an nfs-enhanced iget variant and implement the
rest of the semantics.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/include/linux/exportfs.h
===
--- linux-2.6.orig/include/linux/exportfs.h 2007-09-13 15:11:11.0 
+0200
+++ linux-2.6/include/linux/exportfs.h  2007-09-13 15:13:57.0 +0200
@@ -4,6 +4,7 @@
 #include linux/types.h
 
 struct dentry;
+struct inode;
 struct super_block;
 struct vfsmount;
 
@@ -101,6 +102,21 @@ struct fid {
  *the filehandle fragment.  encode_fh() should return the number of bytes
  *stored or a negative error code such as %-ENOSPC
  *
+ * fh_to_dentry:
+ *@fh_to_dentry is given a struct super_block (@sb) and a file handle
+ *fragment (@fh, @fh_len). It should return a struct dentry which refers
+ *to the same file that the file handle fragment refers to.  If it cannot,
+ *it should return a %NULL pointer if the file was found but no acceptable
+ *dentries were available, or an %ERR_PTR error code indicating why it
+ *couldn't be found (e.g. %ENOENT or %ENOMEM).  Any suitable dentry can be
+ *returned including, if necessary, a new dentry created with d_alloc_root.
+ *The caller can then find any other extant dentries by following the
+ *d_alias links.
+ *
+ * fh_to_parent:
+ *Same as @fh_to_dentry, except that it returns a pointer to the parent
+ *dentry if it was encoded into the filehandle fragment by @encode_fh.
+ *
  * get_name:
  *@get_name should find a name for the given @child in the given @parent
  *directory.  The name should be stored in the @name (with the
@@ -139,6 +155,10 @@ struct export_operations {
void *context);
int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
int connectable);
+   struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type);
+   struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type);
int (*get_name)(struct dentry *parent, char *name,
struct dentry *child);
struct dentry * (*get_parent)(struct dentry *child);
@@ -161,4 +181,14 @@ extern struct dentry *exportfs_decode_fh
int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
void *context);
 
+/*
+ * Generic helpers for filesystems.
+ */
+extern struct dentry *generic_fh_to_dentry(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type,
+   struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
+extern struct dentry *generic_fh_to_parent(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type,
+   struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
+
 #endif /* LINUX_EXPORTFS_H */
Index: linux-2.6/fs/exportfs/expfs.c
===
--- linux-2.6.orig/fs/exportfs/expfs.c  2007-09-13 15:13:02.0 +0200
+++ linux-2.6/fs/exportfs/expfs.c   2007-09-13 15:14:42.0 +0200
@@ -514,17 +514,141 @@ struct dentry *exportfs_decode_fh(struct
int (*acceptable)(void *, struct dentry *), void *context)
 {
struct export_operations *nop = mnt-mnt_sb-s_export_op;
-   struct dentry *result;
+   struct dentry *result, *alias;
+   int err;
 
-   if (nop-decode_fh) {
-   result = nop-decode_fh(mnt-mnt_sb, fid-raw, fh_len,
+   /*
+* Old way of doing things.  Will go away soon.
+*/
+   if (!nop-fh_to_dentry) {
+   if (nop-decode_fh) {
+   return nop-decode_fh(mnt-mnt_sb, fid-raw, fh_len,
fileid_type, acceptable, context);
+   } else {
+   return export_decode_fh(mnt-mnt_sb, fid-raw, fh_len,
+   fileid_type, acceptable, context);
+   }
+   }
+
+   /*
+* Try to get any dentry for the given file handle from the filesystem.
+*/
+   result = nop-fh_to_dentry(mnt-mnt_sb, fid, fh_len, fileid_type);
+   if (!result)
+   result = ERR_PTR(-ESTALE);
+   if (IS_ERR(result))
+   return result;
+
+   if (S_ISDIR(result-d_inode-i_mode)) {
+   /*
+* This request is for a directory.
+*
+* On the positive side there is only one dentry for each

[PATCH 05/18] ext4: new export ops

2007-09-19 Thread Christoph Hellwig
Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/ext4/super.c
===
--- linux-2.6.orig/fs/ext4/super.c  2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/ext4/super.c   2007-09-13 15:18:21.0 +0200
@@ -613,13 +613,10 @@ static int ext4_show_options(struct seq_
 }
 
 
-static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp)
+static struct inode *ext4_nfs_get_inode(struct super_block *sb,
+   u64 ino, u32 generation)
 {
-   __u32 *objp = vobjp;
-   unsigned long ino = objp[0];
-   __u32 generation = objp[1];
struct inode *inode;
-   struct dentry *result;
 
if (ino  EXT4_FIRST_INO(sb)  ino != EXT4_ROOT_INO)
return ERR_PTR(-ESTALE);
@@ -642,15 +639,22 @@ static struct dentry *ext4_get_dentry(st
iput(inode);
return ERR_PTR(-ESTALE);
}
-   /* now to find a dentry.
-* If possible, get a well-connected one
-*/
-   result = d_alloc_anon(inode);
-   if (!result) {
-   iput(inode);
-   return ERR_PTR(-ENOMEM);
-   }
-   return result;
+
+   return inode;
+}
+
+static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+   ext4_nfs_get_inode);
+}
+
+static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+   ext4_nfs_get_inode);
 }
 
 #ifdef CONFIG_QUOTA
@@ -720,8 +724,9 @@ static const struct super_operations ext
 };
 
 static struct export_operations ext4_export_ops = {
+   .fh_to_dentry = ext4_fh_to_dentry,
+   .fh_to_parent = ext4_fh_to_parent,
.get_parent = ext4_get_parent,
-   .get_dentry = ext4_get_dentry,
 };
 
 enum {

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/18] efs: new export ops

2007-09-19 Thread Christoph Hellwig
Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/efs/namei.c
===
--- linux-2.6.orig/fs/efs/namei.c   2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/efs/namei.c2007-09-13 15:19:00.0 +0200
@@ -10,6 +10,8 @@
 #include linux/string.h
 #include linux/efs_fs.h
 #include linux/smp_lock.h
+#include linux/exportfs.h
+
 
 static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int 
len) {
struct buffer_head *bh;
@@ -75,13 +77,10 @@ struct dentry *efs_lookup(struct inode *
return NULL;
 }
 
-struct dentry *efs_get_dentry(struct super_block *sb, void *vobjp)
+static struct inode *efs_nfs_get_inode(struct super_block *sb, u64 ino,
+   u32 generation)
 {
-   __u32 *objp = vobjp;
-   unsigned long ino = objp[0];
-   __u32 generation = objp[1];
struct inode *inode;
-   struct dentry *result;
 
if (ino == 0)
return ERR_PTR(-ESTALE);
@@ -91,20 +90,25 @@ struct dentry *efs_get_dentry(struct sup
 
if (is_bad_inode(inode) ||
(generation  inode-i_generation != generation)) {
-   result = ERR_PTR(-ESTALE);
-   goto out_iput;
+   iput(inode);
+   return ERR_PTR(-ESTALE);
}
 
-   result = d_alloc_anon(inode);
-   if (!result) {
-   result = ERR_PTR(-ENOMEM);
-   goto out_iput;
-   }
-   return result;
+   return inode;
+}
 
- out_iput:
-   iput(inode);
-   return result;
+struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+   efs_nfs_get_inode);
+}
+
+struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+   efs_nfs_get_inode);
 }
 
 struct dentry *efs_get_parent(struct dentry *child)
Index: linux-2.6/fs/efs/super.c
===
--- linux-2.6.orig/fs/efs/super.c   2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/efs/super.c2007-09-13 15:18:26.0 +0200
@@ -114,7 +114,8 @@ static const struct super_operations efs
 };
 
 static struct export_operations efs_export_ops = {
-   .get_dentry = efs_get_dentry,
+   .fh_to_dentry   = efs_fh_to_dentry,
+   .fh_to_parent   = efs_fh_to_parent,
.get_parent = efs_get_parent,
 };
 
Index: linux-2.6/include/linux/efs_fs.h
===
--- linux-2.6.orig/include/linux/efs_fs.h   2007-09-13 15:10:46.0 
+0200
+++ linux-2.6/include/linux/efs_fs.h2007-09-13 15:18:26.0 +0200
@@ -35,6 +35,7 @@ static inline struct efs_sb_info *SUPER_
 }
 
 struct statfs;
+struct fid;
 
 extern const struct inode_operations efs_dir_inode_operations;
 extern const struct file_operations efs_dir_operations;
@@ -45,7 +46,10 @@ extern efs_block_t efs_map_block(struct 
 extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 
 extern struct dentry *efs_lookup(struct inode *, struct dentry *, struct 
nameidata *);
-extern struct dentry *efs_get_dentry(struct super_block *sb, void *vobjp);
+extern struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type);
+extern struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type);
 extern struct dentry *efs_get_parent(struct dentry *);
 extern int efs_bmap(struct inode *, int);
 

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/18] ntfs: new export ops

2007-09-19 Thread Christoph Hellwig
Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]


Index: linux-2.6/fs/ntfs/namei.c
===
--- linux-2.6.orig/fs/ntfs/namei.c  2007-09-13 15:10:45.0 +0200
+++ linux-2.6/fs/ntfs/namei.c   2007-09-13 15:20:12.0 +0200
@@ -450,58 +450,40 @@ try_next:
return parent_dent;
 }
 
-/**
- * ntfs_get_dentry - find a dentry for the inode from a file handle 
sub-fragment
- * @sb:super block identifying the mounted ntfs volume
- * @fh:the file handle sub-fragment
- *
- * Find a dentry for the inode given a file handle sub-fragment.  This function
- * is called from fs/exportfs/expfs.c::find_exported_dentry() which in turn is
- * called from the default -decode_fh() which is export_decode_fh() in the
- * same file.  The code is closely based on the default -get_dentry() helper
- * fs/exportfs/expfs.c::get_object().
- *
- * The @fh contains two 32-bit unsigned values, the first one is the inode
- * number and the second one is the inode generation.
- *
- * Return the dentry on success or the error code on error (IS_ERR() is true).
- */
-static struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh)
+static struct inode *ntfs_nfs_get_inode(struct super_block *sb,
+   u64 ino, u32 generation)
 {
-   struct inode *vi;
-   struct dentry *dent;
-   unsigned long ino = ((u32 *)fh)[0];
-   u32 gen = ((u32 *)fh)[1];
-
-   ntfs_debug(Entering for inode 0x%lx, generation 0x%x., ino, gen);
-   vi = ntfs_iget(sb, ino);
-   if (IS_ERR(vi)) {
-   ntfs_error(sb, Failed to get inode 0x%lx., ino);
-   return (struct dentry *)vi;
-   }
-   if (unlikely(is_bad_inode(vi) || vi-i_generation != gen)) {
-   /* We didn't find the right inode. */
-   ntfs_error(sb, Inode 0x%lx, bad count: %d %d or version 0x%x 
-   0x%x., vi-i_ino, vi-i_nlink,
-   atomic_read(vi-i_count), vi-i_generation,
-   gen);
-   iput(vi);
-   return ERR_PTR(-ESTALE);
-   }
-   /* Now find a dentry.  If possible, get a well-connected one. */
-   dent = d_alloc_anon(vi);
-   if (unlikely(!dent)) {
-   iput(vi);
-   return ERR_PTR(-ENOMEM);
+   struct inode *inode;
+
+   inode = ntfs_iget(sb, ino);
+   if (!IS_ERR(inode)) {
+   if (is_bad_inode(inode) || inode-i_generation != generation) {
+   iput(inode);
+   inode = ERR_PTR(-ESTALE);
+   }
}
-   ntfs_debug(Done for inode 0x%lx, generation 0x%x., ino, gen);
-   return dent;
+
+   return inode;
+}
+
+static struct dentry *ntfs_fh_to_dentry(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+   ntfs_nfs_get_inode);
+}
+
+static struct dentry *ntfs_fh_to_parent(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+   ntfs_nfs_get_inode);
 }
 
 /**
  * Export operations allowing NFS exporting of mounted NTFS partitions.
  *
- * We use the default -decode_fh() and -encode_fh() for now.  Note that they
+ * We use the default -encode_fh() for now.  Note that they
  * use 32 bits to store the inode number which is an unsigned long so on 64-bit
  * architectures is usually 64 bits so it would all fail horribly on huge
  * volumes.  I guess we need to define our own encode and decode fh functions
@@ -520,7 +502,6 @@ static struct dentry *ntfs_get_dentry(st
 struct export_operations ntfs_export_ops = {
.get_parent = ntfs_get_parent,  /* Find the parent of a given
   directory. */
-   .get_dentry = ntfs_get_dentry,  /* Find a dentry for the inode
-  given a file handle
-  sub-fragment. */
+   .fh_to_dentry   = ntfs_fh_to_dentry,
+   .fh_to_parent   = ntfs_fh_to_parent,
 };

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/18] jfs: new export ops

2007-09-19 Thread Christoph Hellwig
Trivial switch over to the new generic helpers.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/jfs/jfs_inode.h
===
--- linux-2.6.orig/fs/jfs/jfs_inode.h   2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/jfs/jfs_inode.h2007-09-13 15:19:06.0 +0200
@@ -18,6 +18,8 @@
 #ifndef_H_JFS_INODE
 #define _H_JFS_INODE
 
+struct fid;
+
 extern struct inode *ialloc(struct inode *, umode_t);
 extern int jfs_fsync(struct file *, struct dentry *, int);
 extern int jfs_ioctl(struct inode *, struct file *,
@@ -32,7 +34,10 @@ extern void jfs_truncate_nolock(struct i
 extern void jfs_free_zero_link(struct inode *);
 extern struct dentry *jfs_get_parent(struct dentry *dentry);
 extern void jfs_get_inode_flags(struct jfs_inode_info *);
-extern struct dentry *jfs_get_dentry(struct super_block *sb, void *vobjp);
+extern struct dentry *jfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type);
+extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type);
 extern void jfs_set_inode_flags(struct inode *);
 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 
Index: linux-2.6/fs/jfs/namei.c
===
--- linux-2.6.orig/fs/jfs/namei.c   2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/jfs/namei.c2007-09-13 15:19:42.0 +0200
@@ -20,6 +20,7 @@
 #include linux/fs.h
 #include linux/ctype.h
 #include linux/quotaops.h
+#include linux/exportfs.h
 #include jfs_incore.h
 #include jfs_superblock.h
 #include jfs_inode.h
@@ -1477,13 +1478,10 @@ static struct dentry *jfs_lookup(struct 
return dentry;
 }
 
-struct dentry *jfs_get_dentry(struct super_block *sb, void *vobjp)
+static struct inode *jfs_nfs_get_inode(struct super_block *sb,
+   u64 ino, u32 generation)
 {
-   __u32 *objp = vobjp;
-   unsigned long ino = objp[0];
-   __u32 generation = objp[1];
struct inode *inode;
-   struct dentry *result;
 
if (ino == 0)
return ERR_PTR(-ESTALE);
@@ -1493,20 +1491,25 @@ struct dentry *jfs_get_dentry(struct sup
 
if (is_bad_inode(inode) ||
(generation  inode-i_generation != generation)) {
-   result = ERR_PTR(-ESTALE);
-   goto out_iput;
+   iput(inode);
+   return ERR_PTR(-ESTALE);
}
 
-   result = d_alloc_anon(inode);
-   if (!result) {
-   result = ERR_PTR(-ENOMEM);
-   goto out_iput;
-   }
-   return result;
+   return inode;
+}
 
- out_iput:
-   iput(inode);
-   return result;
+struct dentry *jfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+   jfs_nfs_get_inode);
+}
+
+struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type)
+{
+   return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+   jfs_nfs_get_inode);
 }
 
 struct dentry *jfs_get_parent(struct dentry *dentry)
Index: linux-2.6/fs/jfs/super.c
===
--- linux-2.6.orig/fs/jfs/super.c   2007-09-13 15:10:46.0 +0200
+++ linux-2.6/fs/jfs/super.c2007-09-13 15:19:06.0 +0200
@@ -738,7 +738,8 @@ static const struct super_operations jfs
 };
 
 static struct export_operations jfs_export_operations = {
-   .get_dentry = jfs_get_dentry,
+   .fh_to_dentry   = jfs_fh_to_dentry,
+   .fh_to_parent   = jfs_fh_to_parent,
.get_parent = jfs_get_parent,
 };
 

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/18] fat: new export ops

2007-09-19 Thread Christoph Hellwig
Very little changes here, fat had a mostly no op decode_fh before
and does not store any parent information.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/fat/inode.c
===
--- linux-2.6.orig/fs/fat/inode.c   2007-03-13 19:22:40.0 +0100
+++ linux-2.6/fs/fat/inode.c2007-03-13 19:23:13.0 +0100
@@ -651,24 +651,15 @@ static const struct super_operations fat
  * of i_logstart is used to store the directory entry offset.
  */
 
-static struct dentry *
-fat_decode_fh(struct super_block *sb, __u32 *fh, int len, int fhtype,
- int (*acceptable)(void *context, struct dentry *de),
- void *context)
-{
-   if (fhtype != 3)
-   return ERR_PTR(-ESTALE);
-   if (len  5)
-   return ERR_PTR(-ESTALE);
-
-   return sb-s_export_op-find_exported_dentry(sb, fh, NULL, acceptable, 
context);
-}
-
-static struct dentry *fat_get_dentry(struct super_block *sb, void *inump)
+static struct dentry *fat_fh_to_dentry(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type)
 {
struct inode *inode = NULL;
struct dentry *result;
-   __u32 *fh = inump;
+   u32 *fh = fid-raw;
+
+   if (fh_len  5 || fh_type != 3)
+   return NULL;
 
inode = iget(sb, fh[0]);
if (!inode || is_bad_inode(inode) || inode-i_generation != fh[1]) {
@@ -782,9 +773,8 @@ out:
 }
 
 static struct export_operations fat_export_ops = {
-   .decode_fh  = fat_decode_fh,
.encode_fh  = fat_encode_fh,
-   .get_dentry = fat_get_dentry,
+   .fh_to_dentry   = fat_fh_to_dentry,
.get_parent = fat_get_parent,
 };
 

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/18] ocfs2: new export ops

2007-09-19 Thread Christoph Hellwig
OCFS2 has it's own 64bit-firendly filehandle format so we can't use
the generic helpers here.  I'll add a struct for the types later.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]


Index: linux-2.6/fs/ocfs2/export.c
===
--- linux-2.6.orig/fs/ocfs2/export.c2007-05-06 13:51:17.0 +0200
+++ linux-2.6/fs/ocfs2/export.c 2007-06-12 15:54:44.0 +0200
@@ -45,9 +45,9 @@ struct ocfs2_inode_handle
u32 ih_generation;
 };
 
-static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp)
+static struct dentry *ocfs2_get_dentry(struct super_block *sb,
+   struct ocfs2_inode_handle *handle)
 {
-   struct ocfs2_inode_handle *handle = vobjp;
struct inode *inode;
struct dentry *result;
 
@@ -200,54 +200,37 @@ bail:
return type;
 }
 
-static struct dentry *ocfs2_decode_fh(struct super_block *sb, u32 *fh_in,
- int fh_len, int fileid_type,
- int (*acceptable)(void *context,
-   struct dentry *de),
- void *context)
+static struct dentry *ocfs2_fh_to_dentry(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type)
 {
-   struct ocfs2_inode_handle handle, parent;
-   struct dentry *ret = NULL;
-   __le32 *fh = (__force __le32 *) fh_in;
-
-   mlog_entry((0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n,
-  sb, fh, fh_len, fileid_type, acceptable, context);
+   struct ocfs2_inode_handle handle;
 
-   if (fh_len  3 || fileid_type  2)
-   goto bail;
+   if (fh_len  3 || fh_type  2)
+   return NULL;
 
-   if (fileid_type == 2) {
-   if (fh_len  6)
-   goto bail;
-
-   parent.ih_blkno = (u64)le32_to_cpu(fh[3])  32;
-   parent.ih_blkno |= (u64)le32_to_cpu(fh[4]);
-   parent.ih_generation = le32_to_cpu(fh[5]);
-
-   mlog(0, Decoding parent: blkno: %llu, generation: %u\n,
-(unsigned long long)parent.ih_blkno,
-parent.ih_generation);
-   }
-
-   handle.ih_blkno = (u64)le32_to_cpu(fh[0])  32;
-   handle.ih_blkno |= (u64)le32_to_cpu(fh[1]);
-   handle.ih_generation = le32_to_cpu(fh[2]);
+   handle.ih_blkno = (u64)le32_to_cpu(fid-raw[0])  32;
+   handle.ih_blkno |= (u64)le32_to_cpu(fid-raw[1]);
+   handle.ih_generation = le32_to_cpu(fid-raw[2]);
+   return ocfs2_get_dentry(sb, handle);
+}
 
-   mlog(0, Encoding fh: blkno: %llu, generation: %u\n,
-(unsigned long long)handle.ih_blkno, handle.ih_generation);
+static struct dentry *ocfs2_fh_to_parent(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type)
+{
+   struct ocfs2_inode_handle parent;
 
-   ret = ocfs2_export_ops.find_exported_dentry(sb, handle, parent,
-   acceptable, context);
+   if (fh_type != 2 || fh_len  6)
+   return NULL;
 
-bail:
-   mlog_exit_ptr(ret);
-   return ret;
+   parent.ih_blkno = (u64)le32_to_cpu(fid-raw[3])  32;
+   parent.ih_blkno |= (u64)le32_to_cpu(fid-raw[4]);
+   parent.ih_generation = le32_to_cpu(fid-raw[5]);
+   return ocfs2_get_dentry(sb, parent);
 }
 
 struct export_operations ocfs2_export_ops = {
-   .decode_fh  = ocfs2_decode_fh,
.encode_fh  = ocfs2_encode_fh,
-
+   .fh_to_dentry   = ocfs2_fh_to_dentry,
+   .fh_to_parent   = ocfs2_fh_to_parent,
.get_parent = ocfs2_get_parent,
-   .get_dentry = ocfs2_get_dentry,
 };

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/18] shmem: new export ops

2007-09-19 Thread Christoph Hellwig
I'm not sure what people were thinking when adding support to
export tmpfs, but here's the conversion anyway:


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/mm/shmem.c
===
--- linux-2.6.orig/mm/shmem.c   2007-02-11 10:46:30.0 +0100
+++ linux-2.6/mm/shmem.c2007-02-11 10:53:12.0 +0100
@@ -1977,33 +1977,25 @@
return ino-i_ino == inum  fh[0] == ino-i_generation;
 }
 
-static struct dentry *shmem_get_dentry(struct super_block *sb, void *vfh)
+static struct dentry *shmem_fh_to_dentry(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type)
 {
-   struct dentry *de = NULL;
struct inode *inode;
-   __u32 *fh = vfh;
-   __u64 inum = fh[2];
-   inum = (inum  32) | fh[1];
+   struct dentry *dentry = NULL;
+   u64 inum = fid-raw[2];
+   inum = (inum  32) | fid-raw[1];
 
-   inode = ilookup5(sb, (unsigned long)(inum+fh[0]), shmem_match, vfh);
+   if (fh_len  3)
+   return NULL;
+
+   inode = ilookup5(sb, (unsigned long)(inum + fid-raw[0]),
+   shmem_match, fid-raw);
if (inode) {
-   de = d_find_alias(inode);
+   dentry = d_find_alias(inode);
iput(inode);
}
 
-   return de? de: ERR_PTR(-ESTALE);
-}
-
-static struct dentry *shmem_decode_fh(struct super_block *sb, __u32 *fh,
-   int len, int type,
-   int (*acceptable)(void *context, struct dentry *de),
-   void *context)
-{
-   if (len  3)
-   return ERR_PTR(-ESTALE);
-
-   return sb-s_export_op-find_exported_dentry(sb, fh, NULL, acceptable,
-   context);
+   return dentry;
 }
 
 static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
@@ -2038,9 +2030,8 @@
 
 static struct export_operations shmem_export_ops = {
.get_parent = shmem_get_parent,
-   .get_dentry = shmem_get_dentry,
.encode_fh  = shmem_encode_fh,
-   .decode_fh  = shmem_decode_fh,
+   .fh_to_dentry   = shmem_fh_to_dentry,
 };
 
 static int shmem_parse_options(char *options, int *mode, uid_t *uid,

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/18] exportfs: remove old methods

2007-09-19 Thread Christoph Hellwig
Now that all filesystems are converted remove support for the
old methods.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/exportfs/expfs.c
===
--- linux-2.6.orig/fs/exportfs/expfs.c  2007-08-29 13:52:01.0 +0200
+++ linux-2.6/fs/exportfs/expfs.c   2007-08-29 14:02:41.0 +0200
@@ -13,19 +13,6 @@ static int get_name(struct dentry *dentr
struct dentry *child);
 
 
-static struct dentry *exportfs_get_dentry(struct super_block *sb, void *obj)
-{
-   struct dentry *result = ERR_PTR(-ESTALE);
-
-   if (sb-s_export_op-get_dentry) {
-   result = sb-s_export_op-get_dentry(sb, obj);
-   if (!result)
-   result = ERR_PTR(-ESTALE);
-   }
-
-   return result;
-}
-
 static int exportfs_get_name(struct dentry *dir, char *name,
struct dentry *child)
 {
@@ -214,125 +201,6 @@ reconnect_path(struct super_block *sb, s
return 0;
 }
 
-/**
- * find_exported_dentry - helper routine to implement 
export_operations-decode_fh
- * @sb:The super_block identifying the filesystem
- * @obj:   An opaque identifier of the object to be found - passed to
- * get_inode
- * @parent:An optional opqaue identifier of the parent of the object.
- * @acceptable:A function used to test possible dentries to see if 
they are
- * acceptable
- * @context:   A parameter to @acceptable so that it knows on what basis to
- * judge.
- *
- * find_exported_dentry is the central helper routine to enable file systems
- * to provide the decode_fh() export_operation.  It's main task is to take
- * an inode, find or create an appropriate dentry structure, and possibly
- * splice this into the dcache in the correct place.
- *
- * The decode_fh() operation provided by the filesystem should call
- * find_exported_dentry() with the same parameters that it received except
- * that instead of the file handle fragment, pointers to opaque identifiers
- * for the object and optionally its parent are passed.  The default decode_fh
- * routine passes one pointer to the start of the filehandle fragment, and
- * one 8 bytes into the fragment.  It is expected that most filesystems will
- * take this approach, though the offset to the parent identifier may well be
- * different.
- *
- * find_exported_dentry() will call get_dentry to get an dentry pointer from
- * the file system.  If any dentry in the d_alias list is acceptable, it will
- * be returned.  Otherwise find_exported_dentry() will attempt to splice a new
- * dentry into the dcache using get_name() and get_parent() to find the
- * appropriate place.
- */
-
-struct dentry *
-find_exported_dentry(struct super_block *sb, void *obj, void *parent,
-int (*acceptable)(void *context, struct dentry *de),
-void *context)
-{
-   struct dentry *result, *alias;
-   int err = -ESTALE;
-
-   /*
-* Attempt to find the inode.
-*/
-   result = exportfs_get_dentry(sb, obj);
-   if (IS_ERR(result))
-   return result;
-
-   if (S_ISDIR(result-d_inode-i_mode)) {
-   if (!(result-d_flags  DCACHE_DISCONNECTED)) {
-   if (acceptable(context, result))
-   return result;
-   err = -EACCES;
-   goto err_result;
-   }
-
-   err = reconnect_path(sb, result);
-   if (err)
-   goto err_result;
-   } else {
-   struct dentry *target_dir, *nresult;
-   char nbuf[NAME_MAX+1];
-
-   alias = find_acceptable_alias(result, acceptable, context);
-   if (alias)
-   return alias;
-
-   if (parent == NULL)
-   goto err_result;
-
-   target_dir = exportfs_get_dentry(sb,parent);
-   if (IS_ERR(target_dir)) {
-   err = PTR_ERR(target_dir);
-   goto err_result;
-   }
-
-   err = reconnect_path(sb, target_dir);
-   if (err) {
-   dput(target_dir);
-   goto err_result;
-   }
-
-   /*
-* As we weren't after a directory, have one more step to go.
-*/
-   err = exportfs_get_name(target_dir, nbuf, result);
-   if (!err) {
-   mutex_lock(target_dir-d_inode-i_mutex);
-   nresult = lookup_one_len(nbuf, target_dir,
-strlen(nbuf));
-   mutex_unlock(target_dir-d_inode-i_mutex);
-   if (!IS_ERR(nresult)) {
-   if (nresult-d_inode) {
-   dput(result

[PATCH 09/18] xfs: new export ops

2007-09-19 Thread Christoph Hellwig
This one is a lot more complicated than the previous ones.  XFS already
had a very clever scheme for supporting 64bit inode numbers in filehandles,
and I've reworked this to be some kind of a prototype for the generic
64bit inode filehandle support.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_export.c
===
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_export.c2007-09-17 
14:01:25.0 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_export.c 2007-09-17 14:06:24.0 
+0200
@@ -33,62 +33,25 @@
 static struct dentry dotdot = { .d_name.name = .., .d_name.len = 2, };
 
 /*
- * XFS encodes and decodes the fileid portion of NFS filehandles
- * itself instead of letting the generic NFS code do it.  This
- * allows filesystems with 64 bit inode numbers to be exported.
- *
- * Note that a side effect is that xfs_vget() won't be passed a
- * zero inode/generation pair under normal circumstances.  As
- * however a malicious client could send us such data, the check
- * remains in that code.
+ * Note that we only accept fileids which are long enough rather than allow
+ * the parent generation number to default to zero.  XFS considers zero a
+ * valid generation number not an invalid/wildcard value.
  */
-
-STATIC struct dentry *
-xfs_fs_decode_fh(
-   struct super_block  *sb,
-   __u32   *fh,
-   int fh_len,
-   int fileid_type,
-   int (*acceptable)(
-   void*context,
-   struct dentry   *de),
-   void*context)
+static int xfs_fileid_length(int fileid_type)
 {
-   xfs_fid_t   ifid;
-   xfs_fid_t   pfid;
-   void*parent = NULL;
-   int is64 = 0;
-   __u32   *p = fh;
-
-#if XFS_BIG_INUMS
-   is64 = (fileid_type  XFS_FILEID_TYPE_64FLAG);
-   fileid_type = ~XFS_FILEID_TYPE_64FLAG;
-#endif
-
-   /*
-* Note that we only accept fileids which are long enough
-* rather than allow the parent generation number to default
-* to zero.  XFS considers zero a valid generation number not
-* an invalid/wildcard value.  There's little point printk'ing
-* a warning here as we don't have the client information
-* which would make such a warning useful.
-*/
-   if (fileid_type  2 ||
-   fh_len  xfs_fileid_length((fileid_type == 2), is64))
-   return NULL;
-
-   p = xfs_fileid_decode_fid2(p, ifid, is64);
-
-   if (fileid_type == 2) {
-   p = xfs_fileid_decode_fid2(p, pfid, is64);
-   parent = pfid;
+   switch (fileid_type) {
+   case FILEID_INO32_GEN:
+   return 2;
+   case FILEID_INO32_GEN_PARENT:
+   return 4;
+   case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG:
+   return 3;
+   case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG:
+   return 6;
}
-
-   fh = (__u32 *)ifid;
-   return sb-s_export_op-find_exported_dentry(sb, fh, parent, 
acceptable, context);
+   return 255; /* invalid */
 }
 
-
 STATIC int
 xfs_fs_encode_fh(
struct dentry   *dentry,
@@ -96,21 +59,21 @@ xfs_fs_encode_fh(
int *max_len,
int connectable)
 {
+   struct fid  *fid = (struct fid *)fh;
+   struct xfs_fid64*fid64 = (struct xfs_fid64 *)fh;
struct inode*inode = dentry-d_inode;
-   int type = 1;
-   __u32   *p = fh;
+   int fileid_type;
int len;
-   int is64 = 0;
-#if XFS_BIG_INUMS
-   if (!(XFS_M(inode-i_sb)-m_flags  XFS_MOUNT_SMALL_INUMS)) {
-   /* filesystem may contain 64bit inode numbers */
-   is64 = XFS_FILEID_TYPE_64FLAG;
-   }
-#endif
 
/* Directories don't need their parent encoded, they have .. */
if (S_ISDIR(inode-i_mode))
-   connectable = 0;
+   fileid_type = FILEID_INO32_GEN;
+   else
+   fileid_type = FILEID_INO32_GEN_PARENT;
+
+   /* filesystem may contain 64bit inode numbers */
+   if (!(XFS_M(inode-i_sb)-m_flags  XFS_MOUNT_SMALL_INUMS))
+   fileid_type |= XFS_FILEID_TYPE_64FLAG;
 
/*
 * Only encode if there is enough space given.  In practice
@@ -118,39 +81,118 @@ xfs_fs_encode_fh(
 * over NFSv2 with the subtree_check export option; the other
 * seven combinations work.  The real answer is don't use v2.
 */
-   len = xfs_fileid_length(connectable, is64);
+   len = xfs_fileid_length(fileid_type);
if (*max_len  len)
return 255;
*max_len = len;
 
-   p

[PATCH 13/18] reiserfs: new export ops

2007-09-19 Thread Christoph Hellwig
Another nice little cleanup by using the new methods.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/reiserfs/inode.c
===
--- linux-2.6.orig/fs/reiserfs/inode.c  2007-09-13 15:10:45.0 +0200
+++ linux-2.6/fs/reiserfs/inode.c   2007-09-13 15:21:12.0 +0200
@@ -1514,19 +1514,20 @@ struct inode *reiserfs_iget(struct super
return inode;
 }
 
-struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp)
+static struct dentry *reiserfs_get_dentry(struct super_block *sb,
+   u32 objectid, u32 dir_id, u32 generation)
+
 {
-   __u32 *data = vobjp;
struct cpu_key key;
struct dentry *result;
struct inode *inode;
 
-   key.on_disk_key.k_objectid = data[0];
-   key.on_disk_key.k_dir_id = data[1];
+   key.on_disk_key.k_objectid = objectid;
+   key.on_disk_key.k_dir_id = dir_id;
reiserfs_write_lock(sb);
inode = reiserfs_iget(sb, key);
-   if (inode  !IS_ERR(inode)  data[2] != 0 
-   data[2] != inode-i_generation) {
+   if (inode  !IS_ERR(inode)  generation != 0 
+   generation != inode-i_generation) {
iput(inode);
inode = NULL;
}
@@ -1543,14 +1544,9 @@ struct dentry *reiserfs_get_dentry(struc
return result;
 }
 
-struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
- int len, int fhtype,
- int (*acceptable) (void *contect,
-struct dentry * de),
- void *context)
+struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type)
 {
-   __u32 obj[3], parent[3];
-
/* fhtype happens to reflect the number of u32s encoded.
 * due to a bug in earlier code, fhtype might indicate there
 * are more u32s then actually fitted.
@@ -1563,32 +1559,28 @@ struct dentry *reiserfs_decode_fh(struct
 *   6 - as above plus generation of directory
 * 6 does not fit in NFSv2 handles
 */
-   if (fhtype  len) {
-   if (fhtype != 6 || len != 5)
+   if (fh_type  fh_len) {
+   if (fh_type != 6 || fh_len != 5)
reiserfs_warning(sb,
-nfsd/reiserfs, fhtype=%d, len=%d - 
odd,
-fhtype, len);
-   fhtype = 5;
+   nfsd/reiserfs, fhtype=%d, len=%d - odd,
+   fh_type, fh_len);
+   fh_type = 5;
}
 
-   obj[0] = data[0];
-   obj[1] = data[1];
-   if (fhtype == 3 || fhtype = 5)
-   obj[2] = data[2];
-   else
-   obj[2] = 0; /* generation number */
+   return reiserfs_get_dentry(sb, fid-raw[0], fid-raw[1],
+   (fh_type == 3 || fh_type = 5) ? fid-raw[2] : 0);
+}
 
-   if (fhtype = 4) {
-   parent[0] = data[fhtype = 5 ? 3 : 2];
-   parent[1] = data[fhtype = 5 ? 4 : 3];
-   if (fhtype == 6)
-   parent[2] = data[5];
-   else
-   parent[2] = 0;
-   }
-   return sb-s_export_op-find_exported_dentry(sb, obj,
-fhtype  4 ? NULL : parent,
-acceptable, context);
+struct dentry *reiserfs_fh_to_parent(struct super_block *sb, struct fid *fid,
+   int fh_len, int fh_type)
+{
+   if (fh_type  4)
+   return NULL;
+
+   return reiserfs_get_dentry(sb,
+   (fh_type = 5) ? fid-raw[3] : fid-raw[2],
+   (fh_type = 5) ? fid-raw[4] : fid-raw[3],
+   (fh_type == 6) ? fid-raw[5] : 0);
 }
 
 int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
Index: linux-2.6/fs/reiserfs/super.c
===
--- linux-2.6.orig/fs/reiserfs/super.c  2007-09-13 15:10:45.0 +0200
+++ linux-2.6/fs/reiserfs/super.c   2007-09-13 15:21:12.0 +0200
@@ -651,9 +651,9 @@ static struct quotactl_ops reiserfs_qctl
 
 static struct export_operations reiserfs_export_ops = {
.encode_fh = reiserfs_encode_fh,
-   .decode_fh = reiserfs_decode_fh,
+   .fh_to_dentry = reiserfs_fh_to_dentry,
+   .fh_to_parent = reiserfs_fh_to_parent,
.get_parent = reiserfs_get_parent,
-   .get_dentry = reiserfs_get_dentry,
 };
 
 /* this struct is used in reiserfs_getopt () for containing the value for those
Index: linux-2.6/include/linux/reiserfs_fs.h
===
--- linux-2.6.orig/include/linux/reiserfs_fs.h  2007-09-13 15:10:45.0 
+0200
+++ linux-2.6/include/linux/reiserfs_fs.h   2007-09

[PATCH 14/18] gfs2: new export ops

2007-09-19 Thread Christoph Hellwig
Convert gfs2 to the new ops.   Uses a similar structure to the generic
helpers, but gfs2 has it's own file handle formats.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]


Index: linux-2.6/fs/gfs2/ops_export.c
===
--- linux-2.6.orig/fs/gfs2/ops_export.c 2007-07-19 15:56:46.0 +0200
+++ linux-2.6/fs/gfs2/ops_export.c  2007-07-20 19:58:06.0 +0200
@@ -31,40 +31,6 @@
 #define GFS2_LARGE_FH_SIZE 8
 #define GFS2_OLD_FH_SIZE 10
 
-static struct dentry *gfs2_decode_fh(struct super_block *sb,
-__u32 *p,
-int fh_len,
-int fh_type,
-int (*acceptable)(void *context,
-  struct dentry *dentry),
-void *context)
-{
-   __be32 *fh = (__force __be32 *)p;
-   struct gfs2_inum_host inum, parent;
-
-   memset(parent, 0, sizeof(struct gfs2_inum));
-
-   switch (fh_len) {
-   case GFS2_LARGE_FH_SIZE:
-   case GFS2_OLD_FH_SIZE:
-   parent.no_formal_ino = ((u64)be32_to_cpu(fh[4]))  32;
-   parent.no_formal_ino |= be32_to_cpu(fh[5]);
-   parent.no_addr = ((u64)be32_to_cpu(fh[6]))  32;
-   parent.no_addr |= be32_to_cpu(fh[7]);
-   case GFS2_SMALL_FH_SIZE:
-   inum.no_formal_ino = ((u64)be32_to_cpu(fh[0]))  32;
-   inum.no_formal_ino |= be32_to_cpu(fh[1]);
-   inum.no_addr = ((u64)be32_to_cpu(fh[2]))  32;
-   inum.no_addr |= be32_to_cpu(fh[3]);
-   break;
-   default:
-   return NULL;
-   }
-
-   return gfs2_export_ops.find_exported_dentry(sb, inum, parent,
-   acceptable, context);
-}
-
 static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len,
  int connectable)
 {
@@ -189,10 +155,10 @@ static struct dentry *gfs2_get_parent(st
return dentry;
 }
 
-static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj)
+static struct dentry *gfs2_get_dentry(struct super_block *sb,
+   struct gfs2_inum_host *inum)
 {
struct gfs2_sbd *sdp = sb-s_fs_info;
-   struct gfs2_inum_host *inum = inum_obj;
struct gfs2_holder i_gh, ri_gh, rgd_gh;
struct gfs2_rgrpd *rgd;
struct inode *inode;
@@ -289,11 +255,50 @@ fail:
return ERR_PTR(error);
 }
 
+static struct dentry *gfs2_fh_to_dentry(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   struct gfs2_inum_host this;
+   __be32 *fh = (__force __be32 *)fid-raw;
+
+   switch (fh_type) {
+   case GFS2_SMALL_FH_SIZE:
+   case GFS2_LARGE_FH_SIZE:
+   case GFS2_OLD_FH_SIZE:
+   this.no_formal_ino = ((u64)be32_to_cpu(fh[0]))  32;
+   this.no_formal_ino |= be32_to_cpu(fh[1]);
+   this.no_addr = ((u64)be32_to_cpu(fh[2]))  32;
+   this.no_addr |= be32_to_cpu(fh[3]);
+   return gfs2_get_dentry(sb, this);
+   default:
+   return NULL;
+   }
+}
+
+static struct dentry *gfs2_fh_to_parent(struct super_block *sb, struct fid 
*fid,
+   int fh_len, int fh_type)
+{
+   struct gfs2_inum_host parent;
+   __be32 *fh = (__force __be32 *)fid-raw;
+
+   switch (fh_type) {
+   case GFS2_LARGE_FH_SIZE:
+   case GFS2_OLD_FH_SIZE:
+   parent.no_formal_ino = ((u64)be32_to_cpu(fh[4]))  32;
+   parent.no_formal_ino |= be32_to_cpu(fh[5]);
+   parent.no_addr = ((u64)be32_to_cpu(fh[6]))  32;
+   parent.no_addr |= be32_to_cpu(fh[7]);
+   return gfs2_get_dentry(sb, parent);
+   default:
+   return NULL;
+   }
+}
+
 struct export_operations gfs2_export_ops = {
-   .decode_fh = gfs2_decode_fh,
.encode_fh = gfs2_encode_fh,
+   .fh_to_dentry = gfs2_fh_to_dentry,
+   .fh_to_parent = gfs2_fh_to_parent,
.get_name = gfs2_get_name,
.get_parent = gfs2_get_parent,
-   .get_dentry = gfs2_get_dentry,
 };
 

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/18] isofs: new export ops

2007-09-19 Thread Christoph Hellwig
Nice little cleanup by consolidating things a little and using   
a structure for the special file handle format.


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/isofs/export.c
===
--- linux-2.6.orig/fs/isofs/export.c2007-02-11 10:31:19.0 +0100
+++ linux-2.6/fs/isofs/export.c 2007-02-11 10:45:25.0 +0100
@@ -42,16 +42,6 @@
return result;
 }
 
-static struct dentry *
-isofs_export_get_dentry(struct super_block *sb, void *vobjp)
-{
-   __u32 *objp = vobjp;
-   unsigned long block = objp[0];
-   unsigned long offset = objp[1];
-   __u32 generation = objp[2];
-   return isofs_export_iget(sb, block, offset, generation);
-}
-
 /* This function is surprisingly simple.  The trick is understanding
  * that child is always a directory. So, to find its parent, you
  * simply need to find its .. entry, normalize its block and offset,
@@ -182,43 +172,44 @@
return type;
 }
 
+struct isofs_fid {
+   u32 block;
+   u16 offset;
+   u16 parent_offset;
+   u32 generation;
+   u32 parent_block;
+   u32 parent_generation;
+};
 
-static struct dentry *
-isofs_export_decode_fh(struct super_block *sb,
-  __u32 *fh32,
-  int fh_len,
-  int fileid_type,
-  int (*acceptable)(void *context, struct dentry *de),
-  void *context)
+static struct dentry *isofs_fh_to_dentry(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type)
 {
-   __u16 *fh16 = (__u16*)fh32;
-   __u32 child[3];   /* The child is what triggered all this. */
-   __u32 parent[3];  /* The parent is just along for the ride. */
+   struct isofs_fid *ifid = (struct isofs_fid *)fid;
 
-   if (fh_len  3 || fileid_type  2)
+   if (fh_len  3 || fh_type  2)
return NULL;
 
-   child[0] = fh32[0];
-   child[1] = fh16[2];  /* fh16 [sic] */
-   child[2] = fh32[2];
-
-   parent[0] = 0;
-   parent[1] = 0;
-   parent[2] = 0;
-   if (fileid_type == 2) {
-   if (fh_len  2) parent[0] = fh32[3];
-   parent[1] = fh16[3];  /* fh16 [sic] */
-   if (fh_len  4) parent[2] = fh32[4];
-   }
-
-   return sb-s_export_op-find_exported_dentry(sb, child, parent,
-acceptable, context);
+   return isofs_export_iget(sb, ifid-block, ifid-offset,
+   ifid-generation);
 }
 
+static struct dentry *isofs_fh_to_parent(struct super_block *sb,
+   struct fid *fid, int fh_len, int fh_type)
+{
+   struct isofs_fid *ifid = (struct isofs_fid *)fid;
+
+   if (fh_type != 2)
+   return NULL;
+
+   return isofs_export_iget(sb,
+   fh_len  2 ? ifid-parent_block : 0,
+   ifid-parent_offset,
+   fh_len  4 ? ifid-parent_generation : 0);
+}
 
 struct export_operations isofs_export_ops = {
-   .decode_fh  = isofs_export_decode_fh,
.encode_fh  = isofs_export_encode_fh,
-   .get_dentry = isofs_export_get_dentry,
+   .fh_to_dentry   = isofs_fh_to_dentry,
+   .fh_to_parent   = isofs_fh_to_parent,
.get_parent = isofs_export_get_parent,
 };

--
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/18] exportfs: make struct export_operations const

2007-09-19 Thread Christoph Hellwig
Now that nfsd has stopped writing to the find_exported_dentry member
we an mark the export_operations const


Signed-off-by: Christoph Hellwig [EMAIL PROTECTED]

Index: linux-2.6/fs/efs/super.c
===
--- linux-2.6.orig/fs/efs/super.c   2007-09-13 15:06:51.0 +0200
+++ linux-2.6/fs/efs/super.c2007-09-13 15:09:05.0 +0200
@@ -113,7 +113,7 @@ static const struct super_operations efs
.remount_fs = efs_remount,
 };
 
-static struct export_operations efs_export_ops = {
+static const struct export_operations efs_export_ops = {
.fh_to_dentry   = efs_fh_to_dentry,
.fh_to_parent   = efs_fh_to_parent,
.get_parent = efs_get_parent,
Index: linux-2.6/fs/ext2/super.c
===
--- linux-2.6.orig/fs/ext2/super.c  2007-09-13 15:05:26.0 +0200
+++ linux-2.6/fs/ext2/super.c   2007-09-13 15:09:05.0 +0200
@@ -292,7 +292,7 @@ static struct dentry *ext2_fh_to_parent(
  * systems, but can be improved upon.
  * Currently only get_parent is required.
  */
-static struct export_operations ext2_export_ops = {
+static const struct export_operations ext2_export_ops = {
.fh_to_dentry = ext2_fh_to_dentry,
.fh_to_parent = ext2_fh_to_parent,
.get_parent = ext2_get_parent,
Index: linux-2.6/fs/ext3/super.c
===
--- linux-2.6.orig/fs/ext3/super.c  2007-09-13 15:06:39.0 +0200
+++ linux-2.6/fs/ext3/super.c   2007-09-13 15:09:05.0 +0200
@@ -670,7 +670,7 @@ static const struct super_operations ext
 #endif
 };
 
-static struct export_operations ext3_export_ops = {
+static const struct export_operations ext3_export_ops = {
.fh_to_dentry = ext3_fh_to_dentry,
.fh_to_parent = ext3_fh_to_parent,
.get_parent = ext3_get_parent,
Index: linux-2.6/fs/ext4/super.c
===
--- linux-2.6.orig/fs/ext4/super.c  2007-09-13 15:06:44.0 +0200
+++ linux-2.6/fs/ext4/super.c   2007-09-13 15:09:05.0 +0200
@@ -721,7 +721,7 @@ static const struct super_operations ext
 #endif
 };
 
-static struct export_operations ext4_export_ops = {
+static const struct export_operations ext4_export_ops = {
.fh_to_dentry = ext4_fh_to_dentry,
.fh_to_parent = ext4_fh_to_parent,
.get_parent = ext4_get_parent,
Index: linux-2.6/fs/fat/inode.c
===
--- linux-2.6.orig/fs/fat/inode.c   2007-09-13 15:08:12.0 +0200
+++ linux-2.6/fs/fat/inode.c2007-09-13 15:09:05.0 +0200
@@ -769,7 +769,7 @@ out:
return parent;
 }
 
-static struct export_operations fat_export_ops = {
+static const struct export_operations fat_export_ops = {
.encode_fh  = fat_encode_fh,
.fh_to_dentry   = fat_fh_to_dentry,
.get_parent = fat_get_parent,
Index: linux-2.6/fs/gfs2/ops_export.c
===
--- linux-2.6.orig/fs/gfs2/ops_export.c 2007-09-13 15:08:53.0 +0200
+++ linux-2.6/fs/gfs2/ops_export.c  2007-09-13 15:09:05.0 +0200
@@ -294,7 +294,7 @@ static struct dentry *gfs2_fh_to_parent(
}
 }
 
-struct export_operations gfs2_export_ops = {
+const struct export_operations gfs2_export_ops = {
.encode_fh = gfs2_encode_fh,
.fh_to_dentry = gfs2_fh_to_dentry,
.fh_to_parent = gfs2_fh_to_parent,
Index: linux-2.6/fs/isofs/export.c
===
--- linux-2.6.orig/fs/isofs/export.c2007-09-13 15:08:18.0 +0200
+++ linux-2.6/fs/isofs/export.c 2007-09-13 15:09:05.0 +0200
@@ -207,7 +207,7 @@ static struct dentry *isofs_fh_to_parent
fh_len  4 ? ifid-parent_generation : 0);
 }
 
-struct export_operations isofs_export_ops = {
+const struct export_operations isofs_export_ops = {
.encode_fh  = isofs_export_encode_fh,
.fh_to_dentry   = isofs_fh_to_dentry,
.fh_to_parent   = isofs_fh_to_parent,
Index: linux-2.6/fs/isofs/isofs.h
===
--- linux-2.6.orig/fs/isofs/isofs.h 2007-09-11 16:23:34.0 +0200
+++ linux-2.6/fs/isofs/isofs.h  2007-09-13 15:09:05.0 +0200
@@ -178,4 +178,4 @@ isofs_normalize_block_and_offset(struct 
 extern const struct inode_operations isofs_dir_inode_operations;
 extern const struct file_operations isofs_dir_operations;
 extern const struct address_space_operations isofs_symlink_aops;
-extern struct export_operations isofs_export_ops;
+extern const struct export_operations isofs_export_ops;
Index: linux-2.6/fs/jfs/super.c
===
--- linux-2.6.orig/fs/jfs/super.c   2007-09-13 15:07:17.0 +0200
+++ linux

  1   2   3   4   >