Whamcloud - gitweb
Branch: b_release_1_4_6
authorwangdi <wangdi>
Sat, 7 Jan 2006 05:18:22 +0000 (05:18 +0000)
committerwangdi <wangdi>
Sat, 7 Jan 2006 05:18:22 +0000 (05:18 +0000)
b=9926
1) shrink the reply buffer for unlink and orphan close
2) retrieve max mdsize and cookiesize in getattr, because in join, max_mdsize and
   cookiesize might change, and all the clients should know this info.
r=adilger

15 files changed:
lustre/include/linux/lustre_idl.h
lustre/llite/file.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_internal.h
lustre/mds/mds_join.c
lustre/mds/mds_lov.c
lustre/mds/mds_open.c
lustre/mds/mds_reint.c
lustre/mds/mds_unlink_open.c
lustre/ptlrpc/pack_generic.c
lustre/tests/sanityN.sh
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 7bab5ce..be38e15 100644 (file)
@@ -653,7 +653,7 @@ struct mds_body {
         __u64          ino;
         __u32          fsuid;
         __u32          fsgid;
-        __u32          capability; /*return max cookie size, in case of join*/
+        __u32          capability; 
         __u32          mode;
         __u32          uid;
         __u32          gid;
@@ -664,8 +664,8 @@ struct mds_body {
         __u32          suppgid;
         __u32          eadatasize;
         __u32          aclsize;
-        __u32          padding_2; /* also fix lustre_swab_mds_body */
-        __u32          padding_3; /* also fix lustre_swab_mds_body */
+        __u32          max_mdsize;
+        __u32          max_cookiesize; /* also fix lustre_swab_mds_body */
         __u32          padding_4; /* also fix lustre_swab_mds_body */
 };
 
index 7767f7f..a5a164b 100644 (file)
@@ -1731,7 +1731,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it)
                         rc = ll_get_max_mdsize(sbi, &ealen);
                         if (rc) 
                                 RETURN(rc); 
-                        valid |= OBD_MD_FLEASIZE;
+                        valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE;
                 }
                 ll_inode2fid(&fid, inode);
                 rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req);
index 080d670..9d2e4df 100644 (file)
@@ -342,7 +342,7 @@ int mdc_enqueue(struct obd_export *exp,
                 repsize[repbufcnt++] = obddev->u.cli.cl_max_mds_cookiesize;
         } else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) {
                 obd_valid valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE |
-                                  OBD_MD_FLACL;
+                                  OBD_MD_FLACL | OBD_MD_FLMODEASIZE;
                 size[req_buffers++] = sizeof(struct mds_body);
                 size[req_buffers++] = data->namelen + 1;
 
@@ -451,22 +451,6 @@ int mdc_enqueue(struct obd_export *exp,
                         CERROR ("Can't swab mds_body\n");
                         RETURN (-EPROTO);
                 }
-                if (body->valid & OBD_MD_FLMODEASIZE) {
-                        LASSERTF(it->it_flags & O_JOIN_FILE,
-                                "flags %#x should include join\n",it->it_flags);
-                        if (obddev->u.cli.cl_max_mds_easize < body->eadatasize){
-                           obddev->u.cli.cl_max_mds_easize = body->eadatasize;
-                                CDEBUG(D_INFO, "change maxeasize to %d,\n",
-                                       body->eadatasize);
-                        }
-                        if (obddev->u.cli.cl_max_mds_cookiesize <
-                            body->capability) {
-                          obddev->u.cli.cl_max_mds_cookiesize =body->capability;
-                                CDEBUG(D_INFO, "change maxcookiesize to %d,\n",
-                                       body->capability);
-                        }
-                        RETURN(rc);
-                }
 
                 if ((body->valid & OBD_MD_FLEASIZE) != 0) {
                         /* The eadata is opaque; just check that it is there.
@@ -477,6 +461,22 @@ int mdc_enqueue(struct obd_export *exp,
                                 CERROR ("Missing/short eadata\n");
                                 RETURN (-EPROTO);
                         }
+                        if (body->valid & OBD_MD_FLMODEASIZE) {
+                                if (obddev->u.cli.cl_max_mds_easize < 
+                                                        body->max_mdsize) {
+                                        obddev->u.cli.cl_max_mds_easize = 
+                                                body->max_mdsize;
+                                        CDEBUG(D_INFO, "maxeasize become %d\n",
+                                               body->max_mdsize);
+                                }
+                                if (obddev->u.cli.cl_max_mds_cookiesize <
+                                                        body->max_cookiesize) {
+                                        obddev->u.cli.cl_max_mds_cookiesize =
+                                                body->max_cookiesize;
+                                        CDEBUG(D_INFO, "cookiesize become %d\n",
+                                               body->max_cookiesize);
+                                }
+                        }
                         /* We save the reply LOV EA in case we have to replay
                          * a create for recovery.  If we didn't allocate a
                          * large enough request buffer above we need to
index 0ec96b9..ca3aab4 100644 (file)
@@ -148,6 +148,16 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
                         RETURN (-EPROTO);
                 }
         }
+        
+        if (body->valid & OBD_MD_FLMODEASIZE) {
+                if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize) 
+                        exp->exp_obd->u.cli.cl_max_mds_easize = 
+                                                body->max_mdsize;
+                if (exp->exp_obd->u.cli.cl_max_mds_cookiesize < 
+                                                body->max_cookiesize)
+                        exp->exp_obd->u.cli.cl_max_mds_cookiesize = 
+                                                body->max_cookiesize;
+        }
 
         RETURN (0);
 }
index ffe80bf..f215e72 100644 (file)
@@ -666,6 +666,13 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
                 reply_off++;
         }
 
+        if (reqbody->valid & OBD_MD_FLMODEASIZE) {
+                struct mds_obd *mds = mds_req2mds(req);
+                body->max_cookiesize = mds->mds_max_cookiesize;
+                body->max_mdsize = mds->mds_max_mdsize;
+                body->valid |= OBD_MD_FLMODEASIZE;
+        }
+
         if (rc)
                 RETURN(rc);
 
index 3fadd4e..34ba5d5 100644 (file)
@@ -177,6 +177,10 @@ int mds_get_parents_children_locked(struct obd_device *obd,
                                     struct dentry **de_newp,
                                     struct lustre_handle *dlm_handles,
                                     int child_mode);
+
+void mds_shrink_reply(struct obd_device *obd, struct ptlrpc_request *req,
+                      struct mds_body *body);
+int mds_get_cookie_size(struct obd_device *obd, struct lov_mds_md *lmm);
 /* mds/mds_lib.c */
 int mds_update_unpack(struct ptlrpc_request *, int offset,
                       struct mds_update_record *);
@@ -231,6 +235,7 @@ int mds_done_writing(struct ptlrpc_request *req, int offset);
 /*mds/mds_join.c*/
 int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req, 
                   struct dentry *dchild, struct lustre_handle *lockh);
+
 /* mds/mds_fs.c */
 int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
                    struct mds_export_data *med, int cl_off);
index 1d81513..599287f 100644 (file)
@@ -216,21 +216,22 @@ static void mds_finish_join(struct mds_obd *mds, struct ptlrpc_request *req,
                                 lustre_msg_buf(req->rq_repmsg, 1, 0);
         int max_cookiesize = lmmj->lmmj_md.lmm_stripe_count *
                                 sizeof(struct llog_cookie);
+        int max_easize = sizeof(*lmmj);
 
         CDEBUG(D_INFO, "change the max md size from %d to %d \n",
                mds->mds_max_mdsize, sizeof(*lmmj));
-        body->eadatasize = mds->mds_max_mdsize > sizeof(*lmmj) ?
-                           mds->mds_max_mdsize : sizeof(*lmmj);
-        if (mds->mds_max_mdsize < body->eadatasize) {
-                mds->mds_max_mdsize = body->eadatasize;
-                body->valid |= OBD_MD_FLMODEASIZE;
-        }
-        if (mds->mds_max_cookiesize < max_cookiesize) {
-                mds->mds_max_cookiesize = max_cookiesize;
-                body->capability = max_cookiesize;
+
+        if (mds->mds_max_mdsize < max_easize || 
+            mds->mds_max_cookiesize < max_cookiesize) {
+                body->max_mdsize = mds->mds_max_mdsize > max_easize ?
+                                   mds->mds_max_mdsize : max_easize;
+                mds->mds_max_mdsize = body->max_mdsize;
+                body->max_cookiesize = mds->mds_max_cookiesize > max_cookiesize?
+                                   mds->mds_max_cookiesize : max_cookiesize;
+                mds->mds_max_cookiesize = body->max_cookiesize;
                 body->valid |= OBD_MD_FLMODEASIZE;
         }
-
+        
         if (body->valid & OBD_MD_FLMODEASIZE)
                 CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n",
                        mds->mds_max_mdsize, mds->mds_max_cookiesize);
index 6e1fe16..6493680 100644 (file)
@@ -148,7 +148,7 @@ int mds_lov_set_nextid(struct obd_device *obd)
 int mds_init_lov_desc(struct obd_device *obd, struct obd_export *osc_exp)
 {
         struct mds_obd *mds = &obd->u.mds;
-        int tgt_count, valsize, rc;
+        int valsize, rc, tgt_count;
         __u32 stripes;
         ENTRY;
 
@@ -163,7 +163,7 @@ int mds_init_lov_desc(struct obd_device *obd, struct obd_export *osc_exp)
                 
         mds->mds_has_lov_desc = 1;
         tgt_count = mds->mds_lov_desc.ld_tgt_count;
-        stripes = min(tgt_count, (__u32)LOV_MAX_STRIPE_COUNT);
+        stripes = min(tgt_count, LOV_MAX_STRIPE_COUNT);
 
         mds->mds_max_mdsize = lov_mds_md_size(stripes);
         mds->mds_max_cookiesize = stripes * sizeof(struct llog_cookie);
index 6546fc6..67d0fbe 100644 (file)
@@ -1409,6 +1409,7 @@ int mds_close(struct ptlrpc_request *req, int offset)
         req->rq_status = mds_mfd_close(req, offset, obd, mfd, 1);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
+        mds_shrink_reply(obd, req, body);
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
                 CERROR("test case OBD_FAIL_MDS_CLOSE_PACK\n");
                 req->rq_status = -ENOMEM;
index ba7961d..fd4f3e3 100644 (file)
@@ -461,7 +461,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         struct mds_logcancel_data *mlcd = NULL;
         struct lov_mds_md *lmm = NULL;
         struct llog_cookie *logcookies = NULL;
-        int lmm_size = 0, need_lock = 1;
+        int lmm_size = 0, need_lock = 1, cookie_size = 0;
         int rc = 0, cleanup_phase = 0, err, locked = 0;
         unsigned int qcids[MAXQUOTAS] = {0, 0};
         unsigned int qpids[MAXQUOTAS] = {rec->ur_iattr.ia_uid,
@@ -546,14 +546,14 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                 rc = fsfilt_setattr(obd, de, handle, &rec->ur_iattr, 0);
                 /* journal chown/chgrp in llog, just like unlink */
                 if (rc == 0 && lmm_size){
-                        OBD_ALLOC(logcookies, mds->mds_max_cookiesize);
+                        cookie_size = mds_get_cookie_size(obd, lmm); 
+                        OBD_ALLOC(logcookies, cookie_size);
                         if (logcookies == NULL)
                                 GOTO(cleanup, rc = -ENOMEM);
 
                         if (mds_log_op_setattr(obd, inode, lmm, lmm_size,
-                                               logcookies,
-                                               mds->mds_max_cookiesize) <= 0) {
-                                OBD_FREE(logcookies, mds->mds_max_cookiesize);
+                                               logcookies, cookie_size) <= 0) {
+                                OBD_FREE(logcookies, cookie_size);
                                 logcookies = NULL;
                         }
                 }
@@ -641,7 +641,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         case 2:
                 OBD_FREE(lmm, mds->mds_max_mdsize);
                 if (logcookies)
-                        OBD_FREE(logcookies, mds->mds_max_cookiesize);
+                        OBD_FREE(logcookies, cookie_size);
         case 1:
                 if ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) &&
                     rec->ur_eadata != NULL)
@@ -1409,6 +1409,35 @@ out_dput:
         RETURN(rc);
 }
 
+int mds_get_cookie_size(struct obd_device *obd, struct lov_mds_md *lmm)
+{
+        int count = le32_to_cpu(lmm->lmm_stripe_count);
+        int real_csize = count * sizeof(struct llog_cookie); 
+        return real_csize;
+}
+
+void mds_shrink_reply(struct obd_device *obd, struct ptlrpc_request *req,
+                      struct mds_body *body)
+{
+        int cookie_size = 0, md_size = 0;
+
+        if (body && body->valid & OBD_MD_FLEASIZE) {
+                md_size = body->eadatasize;
+        }
+        if (body && body->valid & OBD_MD_FLCOOKIE) {
+                LASSERT(body->valid & OBD_MD_FLEASIZE);
+                cookie_size = mds_get_cookie_size(obd, lustre_msg_buf(
+                                                  req->rq_repmsg, 1, 0));
+        }
+
+        CDEBUG(D_INFO, "Shrink to md_size %d cookie_size %d \n", md_size,
+               cookie_size);
+        lustre_shrink_reply(req, 1, md_size, 1);
+        
+        lustre_shrink_reply(req, md_size? 2:1, cookie_size, 0); 
+}
+
 static int mds_reint_unlink(struct mds_update_record *rec, int offset,
                             struct ptlrpc_request *req,
                             struct lustre_handle *lh)
@@ -1631,6 +1660,8 @@ cleanup:
         }
         req->rq_status = rc;
 
+        mds_shrink_reply(obd, req, body);
+
         /* trigger dqrel on the owner of child and parent */
         lquota_adjust(quota_interface, obd, qcids, qpids, rc, FSFILT_OP_UNLINK);
         return 0;
index c459f7d..cf487cb 100644 (file)
@@ -100,7 +100,7 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild,
         struct mds_obd *mds = &obd->u.mds;
         struct lov_mds_md *lmm = NULL;
         struct llog_cookie *logcookies = NULL;
-        int lmm_size, log_unlink = 0;
+        int lmm_size, log_unlink = 0, cookie_size = 0;
         void *handle = NULL;
         int rc, err;
         ENTRY;
@@ -140,11 +140,12 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild,
                 CERROR("error %d unlinking orphan %.*s from PENDING\n",
                        rc, dchild->d_name.len, dchild->d_name.name);
         } else if (lmm_size) {
-                OBD_ALLOC(logcookies, mds->mds_max_cookiesize);
+                cookie_size = mds_get_cookie_size(obd, lmm); 
+                OBD_ALLOC(logcookies, cookie_size);
                 if (logcookies == NULL)
                         rc = -ENOMEM;
                 else if (mds_log_op_unlink(obd, inode, lmm,lmm_size,logcookies,
-                                           mds->mds_max_cookiesize) > 0)
+                                           cookie_size) > 0)
                         log_unlink = 1;
         }
 
@@ -159,7 +160,7 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild,
         }
 
         if (logcookies != NULL)
-                OBD_FREE(logcookies, mds->mds_max_cookiesize);
+                OBD_FREE(logcookies, cookie_size);
 out_free_lmm:
         OBD_FREE(lmm, mds->mds_max_mdsize);
         RETURN(rc);
index de0a21d..68d812b 100644 (file)
@@ -623,8 +623,8 @@ void lustre_swab_mds_body (struct mds_body *b)
         __swab32s (&b->suppgid);
         __swab32s (&b->eadatasize);
         __swab32s (&b->aclsize);
-        __swab32s (&b->padding_2);
-        __swab32s (&b->padding_3);
+        __swab32s (&b->max_mdsize);
+        __swab32s (&b->max_cookiesize);
         __swab32s (&b->padding_4);
 }
 
@@ -1748,14 +1748,14 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct mds_body, aclsize));
         LASSERTF((int)sizeof(((struct mds_body *)0)->aclsize) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct mds_body *)0)->aclsize));
-        LASSERTF((int)offsetof(struct mds_body, padding_2) == 156, " found %lld\n",
-                 (long long)(int)offsetof(struct mds_body, padding_2));
-        LASSERTF((int)sizeof(((struct mds_body *)0)->padding_2) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct mds_body *)0)->padding_2));
-        LASSERTF((int)offsetof(struct mds_body, padding_3) == 160, " found %lld\n",
-                 (long long)(int)offsetof(struct mds_body, padding_3));
-        LASSERTF((int)sizeof(((struct mds_body *)0)->padding_3) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct mds_body *)0)->padding_3));
+        LASSERTF((int)offsetof(struct mds_body, max_mdsize) == 156, " found %lld\n",
+                 (long long)(int)offsetof(struct mds_body, max_mdsize));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->max_mdsize) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct mds_body *)0)->max_mdsize));
+        LASSERTF((int)offsetof(struct mds_body, max_cookiesize) == 160, " found %lld\n",
+                 (long long)(int)offsetof(struct mds_body, max_cookiesize));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->max_cookiesize) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct mds_body *)0)->max_cookiesize));
         LASSERTF((int)offsetof(struct mds_body, padding_4) == 164, " found %lld\n",
                  (long long)(int)offsetof(struct mds_body, padding_4));
         LASSERTF((int)sizeof(((struct mds_body *)0)->padding_4) == 4, " found %lld\n",
index 9413779..9b753a3 100644 (file)
@@ -444,6 +444,25 @@ test_21() { # Bug 5907
 }
 run_test 21 " Try to remove mountpoint on another dir ===="
 
+JOIN=${JOIN:-"lfs join"}
+
+test_22() { # Bug 9926
+       mkdir $DIR1/d21
+       dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
+       cp -p $DIR1/d21/128k $DIR1/d21/f_head
+       for ((i=0;i<10;i++)); do
+               cp -p $DIR1/d21/128k $DIR1/d21/f_tail
+               $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
+               $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
+       done
+       echo aaaaaaaaaaa >> $DIR1/d21/no_joined
+
+       mv $DIR2/d21/f_head $DIR2/
+       munlink $DIR2/f_head || error "unlink joined file error"
+       cat $DIR2/d21/no_joined || error "cat error"
+       rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
+}
+run_test 22 " After joining in one dir,  open/close unlink file in anther dir" 
 
 log "cleanup: ======================================================"
 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
index 53c0fda..dedc74f 100644 (file)
@@ -334,8 +334,8 @@ check_mds_body(void)
         CHECK_MEMBER(mds_body, suppgid);
         CHECK_MEMBER(mds_body, eadatasize);
         CHECK_MEMBER(mds_body, aclsize);
-        CHECK_MEMBER(mds_body, padding_2);
-        CHECK_MEMBER(mds_body, padding_3);
+        CHECK_MEMBER(mds_body, max_mdsize);
+        CHECK_MEMBER(mds_body, max_cookiesize);
         CHECK_MEMBER(mds_body, padding_4);
 
         CHECK_VALUE(FMODE_READ);
index d77c19e..b56fe73 100644 (file)
@@ -839,14 +839,14 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct mds_body, aclsize));
         LASSERTF((int)sizeof(((struct mds_body *)0)->aclsize) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct mds_body *)0)->aclsize));
-        LASSERTF((int)offsetof(struct mds_body, padding_2) == 156, " found %lld\n",
-                 (long long)(int)offsetof(struct mds_body, padding_2));
-        LASSERTF((int)sizeof(((struct mds_body *)0)->padding_2) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct mds_body *)0)->padding_2));
-        LASSERTF((int)offsetof(struct mds_body, padding_3) == 160, " found %lld\n",
-                 (long long)(int)offsetof(struct mds_body, padding_3));
-        LASSERTF((int)sizeof(((struct mds_body *)0)->padding_3) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct mds_body *)0)->padding_3));
+        LASSERTF((int)offsetof(struct mds_body, max_mdsize) == 156, " found %lld\n",
+                 (long long)(int)offsetof(struct mds_body, max_mdsize));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->max_mdsize) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct mds_body *)0)->max_mdsize));
+        LASSERTF((int)offsetof(struct mds_body, max_cookiesize) == 160, " found %lld\n",
+                 (long long)(int)offsetof(struct mds_body, max_cookiesize));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->max_cookiesize) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct mds_body *)0)->max_cookiesize));
         LASSERTF((int)offsetof(struct mds_body, padding_4) == 164, " found %lld\n",
                  (long long)(int)offsetof(struct mds_body, padding_4));
         LASSERTF((int)sizeof(((struct mds_body *)0)->padding_4) == 4, " found %lld\n",