From 3376c6efabd4a48d865350d33de73e767632a6da 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. Lustre-change: http://review.whamcloud.com/9835 Lustre-commit: a11c69ad81ca8071b9d97d5032539dd7b36873ee Change-Id: I4a4fe0681f2cd9dd6f242a03c75326acde02ae05 Signed-off-by: wang di Reviewed-on: http://review.whamcloud.com/10020 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Fan Yong 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 9c38c41..ec52ec6 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1661,6 +1661,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 bc93763..9c56a50 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -563,6 +563,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 0fb33c8..1d859f3 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"); @@ -1230,6 +1232,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. @@ -1253,13 +1256,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