All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junxiao Bi <junxiao.bi@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH] ocfs2: protect get_block with inode cluster lock
Date: Tue, 10 Sep 2019 10:30:46 -0700	[thread overview]
Message-ID: <20190910173046.27360-1-junxiao.bi@oracle.com> (raw)

Inode cluster lock should be acquired to avoid extent
tree changed by other cluster nodes.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
---
 fs/ocfs2/aops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index a4c905d6b575..5ae7253d04b0 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -127,9 +127,15 @@ static int ocfs2_lock_get_block(struct inode *inode, sector_t iblock,
 	int ret = 0;
 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
 
+	ret = ocfs2_inode_lock(inode, NULL, 0);
+	if (ret) {
+		mlog_errno(ret);
+		return ret;
+	}
 	down_read(&oi->ip_alloc_sem);
 	ret = ocfs2_get_block(inode, iblock, bh_result, create);
 	up_read(&oi->ip_alloc_sem);
+	ocfs2_inode_unlock(inode, 0);
 
 	return ret;
 }
-- 
2.17.1

             reply	other threads:[~2019-09-10 17:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 17:30 Junxiao Bi [this message]
2019-09-11  1:32 ` [Ocfs2-devel] [PATCH] ocfs2: protect get_block with inode cluster lock Joseph Qi
2019-09-11  2:33 ` Changwei Ge
2019-09-11 17:40   ` Junxiao Bi
2019-09-12  9:34     ` Gang He
2019-09-12 10:26       ` Changwei Ge
2019-09-12 10:54         ` Gang He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910173046.27360-1-junxiao.bi@oracle.com \
    --to=junxiao.bi@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.