From f4547f0569774eb794fb143362e201f658415f4c Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Sat, 12 Jan 2013 08:30:37 +0800 Subject: [PATCH 1/1] LU-1866 misc: fix some issues found during LFSCK 1) Test scripts issues for sanity.sh and sanity-scrub.sh 2) Incorrectly use open flag 'MDS_OPEN_OWNEROVERRIDE" for permission check for set_attr. 3) Other code clean, such as mdt_body, md_op_spec, wiretest. Signed-off-by: Fan Yong Change-Id: I52fbfe8481e35edba75e8fe7e0ab2fec094eabae Reviewed-on: http://review.whamcloud.com/5046 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: wangdi --- lustre/include/lustre/lustre_idl.h | 5 +++-- lustre/include/md_object.h | 8 ++++---- lustre/mdd/mdd_dir.c | 3 +-- lustre/mdd/mdd_object.c | 8 ++++---- lustre/mdt/mdt_handler.c | 6 ------ lustre/mdt/mdt_lib.c | 12 ++++++------ lustre/osp/osp_dev.c | 2 +- lustre/ptlrpc/pack_generic.c | 4 ++-- lustre/ptlrpc/wiretest.c | 16 ++++++++-------- lustre/tests/sanity-scrub.sh | 10 +--------- lustre/tests/sanity.sh | 4 +++- lustre/utils/wirecheck.c | 4 ++-- lustre/utils/wiretest.c | 16 ++++++++-------- 13 files changed, 43 insertions(+), 55 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 7f3f71a..060c252 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2007,7 +2007,7 @@ struct mdt_body { obd_time ctime; __u64 blocks; /* XID, in the case of MDS_READPAGE */ __u64 ioepoch; - __u64 ino; + __u64 unused1; /* was "ino" until 2.4.0 */ __u32 fsuid; __u32 fsgid; __u32 capability; @@ -2017,7 +2017,7 @@ struct mdt_body { __u32 flags; /* from vfs for pin/unpin, LUSTRE_BFLAG close */ __u32 rdev; __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */ - __u32 generation; + __u32 unused2; /* was "generation" until 2.4.0 */ __u32 suppgid; __u32 eadatasize; __u32 aclsize; @@ -2192,6 +2192,7 @@ enum { MDS_RECOV_OPEN = 1 << 8, MDS_DATA_MODIFIED = 1 << 9, MDS_CREATE_VOLATILE = 1 << 10, + MDS_OWNEROVERRIDE = 1 << 11, }; /* instance of mdt_reint_rec */ diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 04f5a52..2048cc6 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -196,14 +196,14 @@ struct md_op_spec { int eadatalen; } sp_ea; } u; - /** don't create lov objects or llog cookie - this replay */ - int no_create; /** Create flag from client: such as MDS_OPEN_CREAT, and others. */ __u64 sp_cr_flags; - /** Should mdd do lookup sanity check or not. */ - int sp_cr_lookup; + /** don't create lov objects or llog cookie - this replay */ + unsigned int no_create:1, + /** Should mdd do lookup sanity check or not. */ + sp_cr_lookup:1; /** Current lock mode for parent dir where create is performing. */ mdl_mode_t sp_cr_mode; diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 0e893c9..5f210b8 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1480,7 +1480,6 @@ static int mdd_create_sanity_check(const struct lu_env *env, struct lu_fid *fid = &info->mti_fid; struct mdd_object *obj = md2mdd_obj(pobj); struct mdd_device *m = mdo2mdd(pobj); - int lookup = spec->sp_cr_lookup; int rc; ENTRY; @@ -1493,7 +1492,7 @@ static int mdd_create_sanity_check(const struct lu_env *env, * exists or not because MDT performs lookup for it. * name length check is done in lookup. */ - if (lookup) { + if (spec->sp_cr_lookup) { /* * Check if the name already exist, though it will be checked in * _index_insert also, for avoiding rolling back if exists diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index da4f2d9..973f893 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -918,14 +918,14 @@ static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj, la->la_valid &= ~(LA_MTIME | LA_CTIME); } else { if (la->la_valid & (LA_SIZE | LA_BLOCKS)) { - if (!((flags & MDS_OPEN_OWNEROVERRIDE) && + if (!((flags & MDS_OWNEROVERRIDE) && (uc->uc_fsuid == tmp_la->la_uid)) && !(flags & MDS_PERM_BYPASS)) { rc = mdd_permission_internal(env, obj, tmp_la, MAY_WRITE); - if (rc) - RETURN(rc); - } + if (rc != 0) + RETURN(rc); + } } if (la->la_valid & LA_CTIME) { /* The pure setattr, it has the priority over what is diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index c8d3b35..b5e0d74 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -398,12 +398,6 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, if (fid) { b->fid1 = *fid; b->valid |= OBD_MD_FLID; - - /* FIXME: these should be fixed when new igif ready.*/ - b->ino = fid_oid(fid); /* 1.6 compatibility */ - b->generation = fid_ver(fid); /* 1.6 compatibility */ - b->valid |= OBD_MD_FLGENER; /* 1.6 compatibility */ - CDEBUG(D_INODE, DFID": nlink=%d, mode=%o, size="LPU64"\n", PFID(fid), b->nlink, b->mode, b->size); } diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 85fa8f5..051421bb 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -573,10 +573,10 @@ int mdt_fix_reply(struct mdt_thread_info *info) acl_size = body->aclsize; /* this replay - not send info to client */ - if (info->mti_spec.no_create == 1) { - md_size = 0; - acl_size = 0; - } + if (info->mti_spec.no_create) { + md_size = 0; + acl_size = 0; + } CDEBUG(D_INFO, "Shrink to md_size = %d cookie/acl_size = %d" " MDSCAPA = %llx, OSSCAPA = %llx\n", @@ -786,8 +786,8 @@ static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr, if (in & ATTR_KILL_SGID) out |= LA_KILL_SGID; - if (in & MDS_OPEN_OWNEROVERRIDE) - ma->ma_attr_flags |= MDS_OPEN_OWNEROVERRIDE; + if (in & MDS_OPEN_OWNEROVERRIDE) + ma->ma_attr_flags |= MDS_OWNEROVERRIDE; if (in & ATTR_FORCE) ma->ma_attr_flags |= MDS_PERM_BYPASS; diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index b2db05e..9a66737 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -733,7 +733,7 @@ out_last_used: out_proc: ptlrpc_lprocfs_unregister_obd(obd); lprocfs_obd_cleanup(obd); - class_destroy_import(obd->u.cli.cl_import); + obd_cleanup_client_import(obd); client_obd_cleanup(obd); out_ref: ptlrpcd_decref(); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 12b0f3b..6de2ad3 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -1878,7 +1878,7 @@ void lustre_swab_mdt_body (struct mdt_body *b) __swab64s (&b->ctime); __swab64s (&b->blocks); __swab64s (&b->ioepoch); - __swab64s (&b->ino); + CLASSERT(offsetof(typeof(*b), unused1) != 0); __swab32s (&b->fsuid); __swab32s (&b->fsgid); __swab32s (&b->capability); @@ -1888,7 +1888,7 @@ void lustre_swab_mdt_body (struct mdt_body *b) __swab32s (&b->flags); __swab32s (&b->rdev); __swab32s (&b->nlink); - __swab32s (&b->generation); + CLASSERT(offsetof(typeof(*b), unused2) != 0); __swab32s (&b->suppgid); __swab32s (&b->eadatasize); __swab32s (&b->aclsize); diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index ff1f7bd..0de4e26 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -1944,10 +1944,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, blocks)); LASSERTF((int)sizeof(((struct mdt_body *)0)->blocks) == 8, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->blocks)); - LASSERTF((int)offsetof(struct mdt_body, ino) == 96, "found %lld\n", - (long long)(int)offsetof(struct mdt_body, ino)); - LASSERTF((int)sizeof(((struct mdt_body *)0)->ino) == 8, "found %lld\n", - (long long)(int)sizeof(((struct mdt_body *)0)->ino)); + LASSERTF((int)offsetof(struct mdt_body, unused1) == 96, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, unused1)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->unused1) == 8, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->unused1)); LASSERTF((int)offsetof(struct mdt_body, fsuid) == 104, "found %lld\n", (long long)(int)offsetof(struct mdt_body, fsuid)); LASSERTF((int)sizeof(((struct mdt_body *)0)->fsuid) == 4, "found %lld\n", @@ -1984,10 +1984,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, nlink)); LASSERTF((int)sizeof(((struct mdt_body *)0)->nlink) == 4, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->nlink)); - LASSERTF((int)offsetof(struct mdt_body, generation) == 140, "found %lld\n", - (long long)(int)offsetof(struct mdt_body, generation)); - LASSERTF((int)sizeof(((struct mdt_body *)0)->generation) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_body *)0)->generation)); + LASSERTF((int)offsetof(struct mdt_body, unused2) == 140, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, unused2)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->unused2) == 4, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->unused2)); LASSERTF((int)offsetof(struct mdt_body, suppgid) == 144, "found %lld\n", (long long)(int)offsetof(struct mdt_body, suppgid)); LASSERTF((int)sizeof(((struct mdt_body *)0)->suppgid) == 4, "found %lld\n", diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index a6754e9..2690661 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -704,7 +704,7 @@ test_11() { # that the number of skipped files is less than 1.5x the number of files local MAXIMUM=$((CREATED * 3 / 2)) local MINIMUM=$((CREATED + 1)) # files + directory - [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM] && + [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM ] && error "(5) Expect [ $MINIMUM , $MAXIMUM ) objects skipped, got $SKIPPED" # reset OI scrub start point by force @@ -723,14 +723,6 @@ test_11() { } run_test 11 "OI scrub skips the new created objects only once" -# restore the ${facet}_MKFS_OPTS variables -for facet in MGS MDS OST; do - opts=SAVED_${facet}_MKFS_OPTS - if [[ -n ${!opts} ]]; then - eval ${facet}_MKFS_OPTS=\"${!opts}\" - fi -done - # restore MDS/OST size MDSSIZE=${SAVED_MDSSIZE} OSTSIZE=${SAVED_OSTSIZE} diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 8572a4e..3c5d753 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5497,7 +5497,9 @@ function get_named_value() done } -export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1` +export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb | + awk '/^max_cached_mb/ { print $2 }') + cleanup_101a() { $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX trap 0 diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 254f5ec..aa8e879 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -875,7 +875,7 @@ check_mdt_body(void) CHECK_MEMBER(mdt_body, atime); CHECK_MEMBER(mdt_body, ctime); CHECK_MEMBER(mdt_body, blocks); - CHECK_MEMBER(mdt_body, ino); + CHECK_MEMBER(mdt_body, unused1); CHECK_MEMBER(mdt_body, fsuid); CHECK_MEMBER(mdt_body, fsgid); CHECK_MEMBER(mdt_body, capability); @@ -885,7 +885,7 @@ check_mdt_body(void) CHECK_MEMBER(mdt_body, flags); CHECK_MEMBER(mdt_body, rdev); CHECK_MEMBER(mdt_body, nlink); - CHECK_MEMBER(mdt_body, generation); + CHECK_MEMBER(mdt_body, unused2); CHECK_MEMBER(mdt_body, suppgid); CHECK_MEMBER(mdt_body, eadatasize); CHECK_MEMBER(mdt_body, aclsize); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 692664a..bb70dbb 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -1952,10 +1952,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, blocks)); LASSERTF((int)sizeof(((struct mdt_body *)0)->blocks) == 8, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->blocks)); - LASSERTF((int)offsetof(struct mdt_body, ino) == 96, "found %lld\n", - (long long)(int)offsetof(struct mdt_body, ino)); - LASSERTF((int)sizeof(((struct mdt_body *)0)->ino) == 8, "found %lld\n", - (long long)(int)sizeof(((struct mdt_body *)0)->ino)); + LASSERTF((int)offsetof(struct mdt_body, unused1) == 96, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, unused1)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->unused1) == 8, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->unused1)); LASSERTF((int)offsetof(struct mdt_body, fsuid) == 104, "found %lld\n", (long long)(int)offsetof(struct mdt_body, fsuid)); LASSERTF((int)sizeof(((struct mdt_body *)0)->fsuid) == 4, "found %lld\n", @@ -1992,10 +1992,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct mdt_body, nlink)); LASSERTF((int)sizeof(((struct mdt_body *)0)->nlink) == 4, "found %lld\n", (long long)(int)sizeof(((struct mdt_body *)0)->nlink)); - LASSERTF((int)offsetof(struct mdt_body, generation) == 140, "found %lld\n", - (long long)(int)offsetof(struct mdt_body, generation)); - LASSERTF((int)sizeof(((struct mdt_body *)0)->generation) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_body *)0)->generation)); + LASSERTF((int)offsetof(struct mdt_body, unused2) == 140, "found %lld\n", + (long long)(int)offsetof(struct mdt_body, unused2)); + LASSERTF((int)sizeof(((struct mdt_body *)0)->unused2) == 4, "found %lld\n", + (long long)(int)sizeof(((struct mdt_body *)0)->unused2)); LASSERTF((int)offsetof(struct mdt_body, suppgid) == 144, "found %lld\n", (long long)(int)offsetof(struct mdt_body, suppgid)); LASSERTF((int)sizeof(((struct mdt_body *)0)->suppgid) == 4, "found %lld\n", -- 1.8.3.1