From: Jeff Layton <jlayton@kernel.org>
To: ceph-devel@vger.kernel.org
Subject: [PATCH] ceph: add a queue_inode_work helper
Date: Mon, 12 Oct 2020 11:16:46 -0400 [thread overview]
Message-ID: <20201012151646.310836-1-jlayton@kernel.org> (raw)
Currently, this is open-coded everywhere. Add a wrapper around
queue_work that takes an inode pointer.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/ceph/inode.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 02b11a4a4d39..7c22bc2ea076 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1801,6 +1801,13 @@ bool ceph_inode_set_size(struct inode *inode, loff_t size)
return ret;
}
+static bool queue_inode_work(struct inode *inode)
+{
+ struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
+
+ return queue_work(fsc->inode_wq, &ceph_inode(inode)->i_work);
+}
+
/*
* Put reference to inode, but avoid calling iput_final() in current thread.
* iput_final() may wait for reahahead pages. The wait can cause deadlock in
@@ -1813,8 +1820,7 @@ void ceph_async_iput(struct inode *inode)
for (;;) {
if (atomic_add_unless(&inode->i_count, -1, 1))
break;
- if (queue_work(ceph_inode_to_client(inode)->inode_wq,
- &ceph_inode(inode)->i_work))
+ if (queue_inode_work(inode))
break;
/* queue work failed, i_count must be at least 2 */
}
@@ -1830,8 +1836,7 @@ void ceph_queue_writeback(struct inode *inode)
set_bit(CEPH_I_WORK_WRITEBACK, &ci->i_work_mask);
ihold(inode);
- if (queue_work(ceph_inode_to_client(inode)->inode_wq,
- &ci->i_work)) {
+ if (queue_inode_work(inode)) {
dout("ceph_queue_writeback %p\n", inode);
} else {
dout("ceph_queue_writeback %p already queued, mask=%lx\n",
@@ -1849,8 +1854,7 @@ void ceph_queue_invalidate(struct inode *inode)
set_bit(CEPH_I_WORK_INVALIDATE_PAGES, &ci->i_work_mask);
ihold(inode);
- if (queue_work(ceph_inode_to_client(inode)->inode_wq,
- &ceph_inode(inode)->i_work)) {
+ if (queue_inode_work(inode)) {
dout("ceph_queue_invalidate %p\n", inode);
} else {
dout("ceph_queue_invalidate %p already queued, mask=%lx\n",
@@ -1869,8 +1873,7 @@ void ceph_queue_vmtruncate(struct inode *inode)
set_bit(CEPH_I_WORK_VMTRUNCATE, &ci->i_work_mask);
ihold(inode);
- if (queue_work(ceph_inode_to_client(inode)->inode_wq,
- &ci->i_work)) {
+ if (queue_inode_work(inode)) {
dout("ceph_queue_vmtruncate %p\n", inode);
} else {
dout("ceph_queue_vmtruncate %p already queued, mask=%lx\n",
--
2.26.2
reply other threads:[~2020-10-12 15:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20201012151646.310836-1-jlayton@kernel.org \
--to=jlayton@kernel.org \
--cc=ceph-devel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).