Whamcloud - gitweb
LU-2786 llite: allow setting pool name via fsetxattr()
authorNed Bass <bass6@llnl.gov>
Fri, 8 Feb 2013 22:09:09 +0000 (14:09 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 20 Feb 2013 02:59:35 +0000 (21:59 -0500)
Setting the pool name in the striping data of a file fails when the
fsetxattr() interface is used to store the lustre extended attributes,
while using ioctl() works as expected.  This is because ll_setxattr()
assumes the size of the lustre user metadata structure to be that of
the older v1 format which doesn't include a pool name field.  Fix this
by using the magic number to detect the format version and setting
the size accordingly when passing the user data down the stack.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Change-Id: I6f6969dfaf2149f268d52272f538fee05459697b
Reviewed-on: http://review.whamcloud.com/5313
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/llite/xattr.c

index 2e4e530..1d9923e 100644 (file)
@@ -239,10 +239,12 @@ int ll_setxattr(struct dentry *dentry, const char *name,
                 if (lump != NULL && S_ISREG(inode->i_mode)) {
                         struct file f;
                         int flags = FMODE_WRITE;
+                       int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ?
+                               sizeof(*lump) : sizeof(struct lov_user_md_v3);
 
-                        f.f_dentry = dentry;
-                        rc = ll_lov_setstripe_ea_info(inode, &f, flags,
-                                                      lump, sizeof(*lump));
+                       f.f_dentry = dentry;
+                       rc = ll_lov_setstripe_ea_info(inode, &f, flags, lump,
+                                                     lum_size);
                         /* b10667: rc always be 0 here for now */
                         rc = 0;
                 } else if (S_ISDIR(inode->i_mode)) {