From 98892021f3d45179c54200e93de134d1d0fba459 Mon Sep 17 00:00:00 2001
From: shadow <shadow>
Date: Wed, 19 Nov 2008 06:02:20 +0000
Subject: [PATCH] fix handle ost additional correctly

Branch b1_6
b=16492
i=umka
i=tappro
---
 lustre/ChangeLog             |  9 ++++++++
 lustre/include/lustre_lite.h |  6 ++++++
 lustre/liblustre/super.c     |  5 +++--
 lustre/llite/llite_lib.c     |  8 ++-----
 lustre/mdc/mdc_locks.c       | 18 ----------------
 lustre/mdc/mdc_request.c     | 10 ---------
 lustre/tests/conf-sanity.sh  | 41 ++++++++++++++++++++++++++++++++++++
 7 files changed, 61 insertions(+), 36 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index d0d723d357..ad77f4a67c 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -42,6 +42,15 @@ tbd Sun Microsystems, Inc.
 	* A new Lustre ADIO driver is available for:
 	  MPICH2-1.0.7
 
+Severity   : normal
+Frequency  : rare, need acls on inode.
+Bugzilla   : 16492
+Description: client can't handle ost additional correctly
+Details    : if ost was added after client connected to mds client can have 
+             hit lnet_try_match_md ... to big messages to wide striped files.
+             in this case need teach client to handle config events about add
+             lov target and update client max ea size at that event.
+
 Severity   : enhancement
 Bugzilla   : 17374
 Description: Update to sles9 kernel-2.6.5-7.314.
diff --git a/lustre/include/lustre_lite.h b/lustre/include/lustre_lite.h
index d83c9b7e48..6543cba352 100644
--- a/lustre/include/lustre_lite.h
+++ b/lustre/include/lustre_lite.h
@@ -130,6 +130,8 @@ struct lustre_client_ocd {
          */
         __u64      lco_flags;
         spinlock_t lco_lock;
+        struct obd_export *lco_mdc_exp;
+        struct obd_export *lco_osc_exp;
 };
 
 /*
@@ -158,7 +160,11 @@ static inline int ll_ocd_update(struct obd_device *host,
                        lco->lco_flags, flags);
                 spin_lock(&lco->lco_lock);
                 lco->lco_flags &= flags;
+                /* for each osc event update ea size */
+                if (lco->lco_osc_exp)
+                        mdc_init_ea_size(lco->lco_mdc_exp, lco->lco_osc_exp);
                 spin_unlock(&lco->lco_lock);
+
                 result = 0;
         } else {
                 CERROR("unexpected notification from %s %s!\n",
diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c
index a70faec6c7..5165d4937f 100644
--- a/lustre/liblustre/super.c
+++ b/lustre/liblustre/super.c
@@ -1999,6 +1999,9 @@ llu_fsswop_mount(const char *source,
         }
         sbi->ll_osc_exp = class_conn2export(&osc_conn);
         sbi->ll_lco.lco_flags = ocd.ocd_connect_flags;
+        sbi->ll_lco.lco_mdc_exp = sbi->ll_mdc_exp;
+        sbi->ll_lco.lco_osc_exp = sbi->ll_osc_exp;
+
 
         err = obd_register_lock_cancel_cb(sbi->ll_osc_exp,
                                           llu_extent_lock_cancel_cb);
@@ -2007,8 +2010,6 @@ llu_fsswop_mount(const char *source,
                 GOTO(out_osc, err);
         }
 
-        mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
-
         err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid);
         if (err) {
                 CERROR("cannot mds_connect: rc = %d\n", err);
diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
index d96f383679..2cd8ddf2e0 100644
--- a/lustre/llite/llite_lib.c
+++ b/lustre/llite/llite_lib.c
@@ -338,6 +338,8 @@ static int client_common_fill_super(struct super_block *sb,
         sbi->ll_osc_exp = class_conn2export(&osc_conn);
         spin_lock(&sbi->ll_lco.lco_lock);
         sbi->ll_lco.lco_flags = data->ocd_connect_flags;
+        sbi->ll_lco.lco_mdc_exp = sbi->ll_mdc_exp;
+        sbi->ll_lco.lco_osc_exp = sbi->ll_osc_exp;
         spin_unlock(&sbi->ll_lco.lco_lock);
 
         err = obd_register_page_removal_cb(sbi->ll_osc_exp,
@@ -354,12 +356,6 @@ static int client_common_fill_super(struct super_block *sb,
                 GOTO(out_page_rm_cb, err);
         }
 
-        err = mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
-        if (err) {
-                CERROR("cannot set max EA and cookie sizes: rc = %d\n", err);
-                GOTO(out_lock_cn_cb, err);
-        }
-
         err = obd_prep_async_page(sbi->ll_osc_exp, NULL, NULL, NULL,
                                   0, NULL, NULL, NULL, 0, NULL);
         if (err < 0) {
diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c
index 0b54a3f0ca..c44fbfe420 100644
--- a/lustre/mdc/mdc_locks.c
+++ b/lustre/mdc/mdc_locks.c
@@ -505,24 +505,6 @@ static int mdc_finish_enqueue(struct obd_export *exp,
                                 CERROR ("Missing/short eadata\n");
                                 RETURN (-EPROTO);
                         }
-                        if (body->valid & OBD_MD_FLMODEASIZE) {
-                                struct obd_device *obddev = class_exp2obd(exp);
-
-                                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
diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index 5702dd758b..2a202b8b33 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -168,16 +168,6 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
                 }
         }
 
-        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);
 }
 
diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh
index 4ad581a2a7..cc64ae22bd 100644
--- a/lustre/tests/conf-sanity.sh
+++ b/lustre/tests/conf-sanity.sh
@@ -1485,6 +1485,47 @@ test_45() { #17310
 }
 run_test 45 "long unlink handling in ptlrpcd"
 
+test_46a() {
+	OSTCOUNT=6
+	reformat
+	start_mds || return 1
+	#first client should see only one ost
+	start_ost || return 2
+	#start_client
+	mount_client $MOUNT || return 3
+	
+	start_ost2 || return 4
+	start ost3 `ostdevname 3` $OST_MOUNT_OPTS || return 5
+	start ost4 `ostdevname 4` $OST_MOUNT_OPTS || return 6
+	start ost5 `ostdevname 5` $OST_MOUNT_OPTS || return 7
+	# wait until ost2-5 is sync
+	sleep 5
+	#second client see both ost's
+
+	mount_client $MOUNT2 || return 8
+	$LFS setstripe $MOUNT2 -c -1 || return 9
+	$LFS getstripe $MOUNT2 || return 10
+
+	echo "ok" > $MOUNT2/widestripe
+	$LFS getstripe $MOUNT2/widestripe || return 11
+	# fill acl buffer for avoid expand lsm to them
+	awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do  
+	    setfacl -m $acl $MOUNT2/widestripe
+	done
+
+	# will be deadlock
+	stat $MOUNT/widestripe || return 12
+
+	umount_client $MOUNT2 || return 13
+	umount_client $MOUNT || return 14
+	stop ost5 -f || return 20
+	stop ost4 -f || return 21
+	stop ost3 -f || return 22
+	stop_ost2 || return 23
+	stop_ost || return 24
+	stop_mds || return 25
+}
+run_test 46a "handle ost additional - wide striped file"
 
 equals_msg `basename $0`: test complete
 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true
-- 
GitLab