From 0409338db056b56800b8be480048706d9ed8d5e0 Mon Sep 17 00:00:00 2001
From: deen <deen>
Date: Thu, 10 Apr 2008 12:50:35 +0000
Subject: [PATCH] Use fsfilt_sync() for both the whole filesystem sync and
 individual file sync to eliminate dangerous inode locking with I_LOCK that
 can lead to a deadlock.

b=15188
i=green
i=shadow
---
 lustre/ChangeLog     |  7 +++++++
 lustre/mds/handler.c | 22 +++++++---------------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 51566505df..f5d575448b 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -485,6 +485,13 @@ Details    : ldlm pool logic depends on number of granted locks equal to
              number of released locks which is not true for flock locks, so
 	     just exclude such locks from consideration.
 
+Severity   : normal
+Bugzilla   : 15188
+Description: MDS deadlock with many ll_sync_lov threads and I/O stalled
+Details    : Use fsfilt_sync() for both the whole filesystem sync and
+             individual file sync to eliminate dangerous inode locking
+             with I_LOCK that can lead to a deadlock.
+
 --------------------------------------------------------------------------------
 
 2007-12-07         Cluster File Systems, Inc. <info@clusterfs.com>
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 7f4d30be88..072591a125 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -1169,30 +1169,22 @@ static int mds_sync(struct ptlrpc_request *req, int offset)
         if (rc)
                 GOTO(out, rc);
 
-        if (body->fid1.id == 0) {
-                /* a fid of zero is taken to mean "sync whole filesystem" */
-                rc = fsfilt_sync(obd, obd->u.obt.obt_sb);
-                GOTO(out, rc);
-        } else {
+        rc = fsfilt_sync(obd, obd->u.obt.obt_sb);
+        if (rc == 0 && body->fid1.id != 0) {
                 struct dentry *de;
 
                 de = mds_fid2dentry(mds, &body->fid1, NULL);
                 if (IS_ERR(de))
                         GOTO(out, rc = PTR_ERR(de));
 
-                /* The file parameter isn't used for anything */
-                if (de->d_inode->i_fop && de->d_inode->i_fop->fsync)
-                        rc = de->d_inode->i_fop->fsync(NULL, de, 1);
-                if (rc == 0) {
-                        body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
-                                              sizeof(*body));
-                        mds_pack_inode2fid(&body->fid1, de->d_inode);
-                        mds_pack_inode2body(body, de->d_inode);
-                }
+                body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+                                      sizeof(*body));
+                mds_pack_inode2fid(&body->fid1, de->d_inode);
+                mds_pack_inode2body(body, de->d_inode);
 
                 l_dput(de);
-                GOTO(out, rc);
         }
+        GOTO(out, rc);
 out:
         req->rq_status = rc;
         return 0;
-- 
GitLab