From a11c69ad81ca8071b9d97d5032539dd7b36873ee Mon Sep 17 00:00:00 2001 From: wang di Date: Thu, 27 Mar 2014 14:18:21 -0700 Subject: [PATCH] LU-4791 lod: subtract xattr overhead when calculate max EA size. 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 Change-Id: Ibe46b8cbc161f151eae4eb14878af4406fc78d41 Reviewed-on: http://review.whamcloud.com/9835 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 1 + lustre/lod/lod_lov.c | 2 ++ lustre/osd-ldiskfs/osd_handler.c | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index b906810..aa2c175 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -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 */ diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 5bd344c..937e7ab 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -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); } diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 7461f9d..e0521af 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -72,6 +72,8 @@ #include #include +#include + 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; } /* -- 1.8.3.1