From 1c7d69ecb08579b7b3ea1fad3f3ea4974aacdbdf Mon Sep 17 00:00:00 2001
From: girish <girish>
Date: Wed, 10 Dec 2008 17:59:24 +0000
Subject: [PATCH] Set MDS_BFLAG_EXT_FLAGS on MDS in open call path. b=17465
 i=adilger i=johann

---
 lustre/include/lustre_export.h |  2 ++
 lustre/mds/handler.c           | 12 ++++++++++++
 lustre/mds/mds_open.c          |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/lustre/include/lustre_export.h b/lustre/include/lustre_export.h
index 69df240e49..4ffd166526 100644
--- a/lustre/include/lustre_export.h
+++ b/lustre/include/lustre_export.h
@@ -138,6 +138,8 @@ struct obd_export {
                                   exp_connecting:1,
                                   exp_replay_needed:1,
                                   exp_need_sync:1, /* needs sync from connect */
+                                  exp_bflag:1,     /* for 1.6 only to track
+                                                      MDS_BFLAG_EXT_FLAGS */
                                   exp_libclient:1; /* liblustre client? */
         struct list_head          exp_queued_rpc;  /* RPC to be handled */
         union {
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 7a41f07793..04c205f96a 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -764,6 +764,18 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
 
         mds_pack_inode2fid(&body->fid1, inode);
         body->flags = reqbody->flags; /* copy MDS_BFLAG_EXT_FLAGS if present */
+
+        /* Compatibility for clients that do not set BLFAG_EXT_FLAGS in
+         * intent lock requests even though they check it in the reply.
+         * In 1.8+ this is set unconditionally, but 1.4.6- clients do
+         * not understand this flag.  b=17465 */
+        if ((reqbody->flags & MDS_BFLAG_EXT_FLAGS) &&
+            !obd->obd_self_export->exp_bflag) {
+                spin_lock(&obd->obd_self_export->exp_lock);
+                obd->obd_self_export->exp_bflag = 1;
+                spin_unlock(&obd->obd_self_export->exp_lock);
+        }
+
         mds_pack_inode2body(body, inode);
         reply_off++;
 
diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c
index ff77e088f9..b471468481 100644
--- a/lustre/mds/mds_open.c
+++ b/lustre/mds/mds_open.c
@@ -1177,6 +1177,8 @@ int mds_open(struct mds_update_record *rec, int offset,
 
 found_child:
         mds_pack_inode2fid(&body->fid1, dchild->d_inode);
+        if (obd->obd_self_export->exp_bflag)
+                body->flags |= MDS_BFLAG_EXT_FLAGS;
         mds_pack_inode2body(body, dchild->d_inode);
 
         if (S_ISREG(dchild->d_inode->i_mode)) {
-- 
GitLab