Whamcloud - gitweb
LU-4791 lod: subtract xattr overhead when calculate max EA size. 35/9835/4
authorwang di <di.wang@intel.com>
Thu, 27 Mar 2014 21:18:21 +0000 (14:18 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 4 Apr 2014 02:47:57 +0000 (02:47 +0000)
1. It needs to subtract the xattr overhead when calculate the max
EA size, otherwise, it might get oversize stripe_count, which cause
ENOSPC error in the following xattr_set.
2. Release stripe information, if xattr set fails.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Ibe46b8cbc161f151eae4eb14878af4406fc78d41
Reviewed-on: http://review.whamcloud.com/9835
Tested-by: Jenkins
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre/lustre_idl.h
lustre/lod/lod_lov.c
lustre/osd-ldiskfs/osd_handler.c

index b906810..aa2c175 100644 (file)
@@ -1716,6 +1716,7 @@ static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
 #define XATTR_NAME_SOM         "trusted.som"
 #define XATTR_NAME_HSM         "trusted.hsm"
 #define XATTR_NAME_LFSCK_NAMESPACE "trusted.lfsck_namespace"
+#define XATTR_NAME_MAX_LEN     32 /* increase this, if there is longer name. */
 
 struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
        __u32 lmm_magic;          /* magic number = LOV_MAGIC_V3 */
index 5bd344c..937e7ab 100644 (file)
@@ -590,6 +590,8 @@ int lod_generate_and_set_lovea(const struct lu_env *env,
        info->lti_buf.lb_len = lmm_size;
        rc = dt_xattr_set(env, next, &info->lti_buf, XATTR_NAME_LOV, 0,
                          th, BYPASS_CAPA);
+       if (rc < 0)
+               lod_object_free_striping(env, lo);
 
        RETURN(rc);
 }
index 7461f9d..e0521af 100644 (file)
@@ -72,6 +72,8 @@
 #include <md_object.h>
 #include <lustre_quota.h>
 
+#include <ldiskfs/xattr.h>
+
 int ldiskfs_pdo = 1;
 CFS_MODULE_PARM(ldiskfs_pdo, "i", int, 0644,
                 "ldiskfs with parallel directory operations");
@@ -1310,6 +1312,7 @@ static void osd_conf_get(const struct lu_env *env,
                          struct dt_device_param *param)
 {
         struct super_block *sb = osd_sb(osd_dt_dev(dev));
+       int                ea_overhead;
 
         /*
          * XXX should be taken from not-yet-existing fs abstraction layer.
@@ -1333,13 +1336,19 @@ static void osd_conf_get(const struct lu_env *env,
         if (test_opt(sb, POSIX_ACL))
                 param->ddp_mntopts |= MNTOPT_ACL;
 
+       /* LOD might calculate the max stripe count based on max_ea_size,
+        * so we need take account in the overhead as well,
+        * xattr_header + magic + xattr_entry_head */
+       ea_overhead = sizeof(struct ldiskfs_xattr_header) + sizeof(__u32) +
+                     LDISKFS_XATTR_LEN(XATTR_NAME_MAX_LEN);
+
 #if defined(LDISKFS_FEATURE_INCOMPAT_EA_INODE)
-        if (LDISKFS_HAS_INCOMPAT_FEATURE(sb, LDISKFS_FEATURE_INCOMPAT_EA_INODE))
-                param->ddp_max_ea_size = LDISKFS_XATTR_MAX_LARGE_EA_SIZE;
-        else
+       if (LDISKFS_HAS_INCOMPAT_FEATURE(sb, LDISKFS_FEATURE_INCOMPAT_EA_INODE))
+               param->ddp_max_ea_size = LDISKFS_XATTR_MAX_LARGE_EA_SIZE -
+                                                               ea_overhead;
+       else
 #endif
-                param->ddp_max_ea_size = sb->s_blocksize;
-
+               param->ddp_max_ea_size = sb->s_blocksize - ea_overhead;
 }
 
 /*