From: Joseph Qi <joseph.qi@linux.alibaba.com> To: ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 1/4] ocfs2: avoid inode removed while nfsd access it Date: Wed, 17 Jun 2020 11:01:12 +0800 Message-ID: <b8f64191-74fc-0f15-affc-e8e518b17bd1@linux.alibaba.com> (raw) In-Reply-To: <20200616183829.87211-2-junxiao.bi@oracle.com> On 2020/6/17 02:38, Junxiao Bi wrote: > When nfsd is getting file dentry using handle or parent dentry of some > dentry, one cluster lock is used to avoid inode removed from other node, > but it still could be removed from local node, so use a rw lock to avoid > this. > > Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> > --- > fs/ocfs2/dlmglue.c | 17 ++++++++++++++++- > fs/ocfs2/ocfs2.h | 1 + > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c > index 152a0fc4e905..751bc4dc7466 100644 > --- a/fs/ocfs2/dlmglue.c > +++ b/fs/ocfs2/dlmglue.c > @@ -689,6 +689,12 @@ static void ocfs2_nfs_sync_lock_res_init(struct ocfs2_lock_res *res, > &ocfs2_nfs_sync_lops, osb); > } > > +static void ocfs2_nfs_sync_lock_init(struct ocfs2_super *osb) > +{ > + ocfs2_nfs_sync_lock_res_init(&osb->osb_nfs_sync_lockres, osb); > + init_rwsem(&osb->nfs_sync_rwlock); > +} > + > void ocfs2_trim_fs_lock_res_init(struct ocfs2_super *osb) > { > struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; > @@ -2855,6 +2861,11 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex) > if (ocfs2_is_hard_readonly(osb)) > return -EROFS; > > + if (ex) > + down_write(&osb->nfs_sync_rwlock); > + else > + down_read(&osb->nfs_sync_rwlock); > + > if (ocfs2_mount_local(osb)) > return 0; > > @@ -2873,6 +2884,10 @@ void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex) > if (!ocfs2_mount_local(osb)) > ocfs2_cluster_unlock(osb, lockres, > ex ? LKM_EXMODE : LKM_PRMODE); > + if (ex) > + up_write(&osb->nfs_sync_rwlock); > + else > + up_read(&osb->nfs_sync_rwlock); > } > > int ocfs2_trim_fs_lock(struct ocfs2_super *osb, > @@ -3340,7 +3355,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) > local: > ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); > ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); > - ocfs2_nfs_sync_lock_res_init(&osb->osb_nfs_sync_lockres, osb); > + ocfs2_nfs_sync_lock_init(osb); > ocfs2_orphan_scan_lock_res_init(&osb->osb_orphan_scan.os_lockres, osb); > > osb->cconn = conn; > diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h > index ee5d98516212..2dd71d626196 100644 > --- a/fs/ocfs2/ocfs2.h > +++ b/fs/ocfs2/ocfs2.h > @@ -395,6 +395,7 @@ struct ocfs2_super > struct ocfs2_lock_res osb_super_lockres; > struct ocfs2_lock_res osb_rename_lockres; > struct ocfs2_lock_res osb_nfs_sync_lockres; > + struct rw_semaphore nfs_sync_rwlock; > struct ocfs2_lock_res osb_trim_fs_lockres; > struct mutex obs_trim_fs_mutex; > struct ocfs2_dlm_debug *osb_dlm_debug; >
next prev parent reply index Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-16 18:38 [Ocfs2-devel] [v2] ocfs2: fix nfsd over ocfs2 issues Junxiao Bi 2020-06-16 18:38 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: avoid inode removed while nfsd access it Junxiao Bi 2020-06-17 3:01 ` Joseph Qi [this message] 2020-06-17 20:57 ` Andrew Morton 2020-06-17 22:56 ` Junxiao Bi 2020-06-16 18:38 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: load global_inode_alloc Junxiao Bi 2020-06-17 3:03 ` Joseph Qi 2020-06-16 18:38 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: fix panic on nfs server over ocfs2 Junxiao Bi 2020-06-17 3:10 ` Joseph Qi 2020-06-16 18:38 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: fix value of OCFS2_INVALID_SLOT Junxiao Bi 2020-06-17 3:26 ` Joseph Qi 2020-07-02 8:48 ` Gang He 2020-07-02 14:13 ` Joseph Qi 2020-07-02 17:51 ` Junxiao Bi 2020-07-03 3:41 ` Gang He 2020-07-03 8:41 ` Gang He 2020-07-03 12:03 ` Joseph Qi 2020-07-03 13:12 ` 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=b8f64191-74fc-0f15-affc-e8e518b17bd1@linux.alibaba.com \ --to=joseph.qi@linux.alibaba.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
OCFS2-Devel Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/ocfs2-devel/0 ocfs2-devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ocfs2-devel ocfs2-devel/ https://lore.kernel.org/ocfs2-devel \ ocfs2-devel@oss.oracle.com public-inbox-index ocfs2-devel Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/com.oracle.oss.ocfs2-devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git