From: Jens Axboe <axboe@kernel.dk>
To: linux-fsdevel@vger.kernel.org
Cc: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk,
Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 3/5] fs: add mnt_want_write_trylock()
Date: Sat, 12 Dec 2020 09:51:03 -0700 [thread overview]
Message-ID: <20201212165105.902688-4-axboe@kernel.dk> (raw)
In-Reply-To: <20201212165105.902688-1-axboe@kernel.dk>
trylock variant of mnt_want_write() - this ends up being pretty trivial,
as we already have a trylock variant of the sb_start_write() helper.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
fs/namespace.c | 18 ++++++++++++++++++
include/linux/mount.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/fs/namespace.c b/fs/namespace.c
index cebaa3e81794..7881cb5595af 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -359,6 +359,24 @@ int mnt_want_write(struct vfsmount *m)
}
EXPORT_SYMBOL_GPL(mnt_want_write);
+/**
+ * mnt_want_write_trylock - try to get write access to a mount
+ * @m: the mount on which to take a write
+ *
+ * trylock variant of @mnt_want_write. See description above.
+ */
+int mnt_want_write_trylock(struct vfsmount *m)
+{
+ int ret;
+
+ if (!sb_start_write_trylock(m->mnt_sb))
+ return -EAGAIN;
+ ret = __mnt_want_write(m);
+ if (ret)
+ sb_end_write(m->mnt_sb);
+ return ret;
+}
+
/**
* mnt_clone_write - get write access to a mount
* @mnt: the mount on which to take a write
diff --git a/include/linux/mount.h b/include/linux/mount.h
index aaf343b38671..e267e622d843 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -78,6 +78,7 @@ struct file; /* forward dec */
struct path;
extern int mnt_want_write(struct vfsmount *mnt);
+extern int mnt_want_write_trylock(struct vfsmount *mnt);
extern int mnt_want_write_file(struct file *file);
extern int mnt_clone_write(struct vfsmount *mnt);
extern void mnt_drop_write(struct vfsmount *mnt);
--
2.29.2
next prev parent reply other threads:[~2020-12-12 16:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-12 16:51 [PATCHSET RFC v2 0/5] fs: Support for LOOKUP_NONBLOCK / RESOLVE_NONBLOCK Jens Axboe
2020-12-12 16:51 ` [PATCH 1/5] fs: make unlazy_walk() error handling consistent Jens Axboe
2020-12-12 16:51 ` [PATCH 2/5] fs: add support for LOOKUP_NONBLOCK Jens Axboe
2020-12-12 16:51 ` Jens Axboe [this message]
2020-12-12 16:51 ` [PATCH 4/5] fs: honor LOOKUP_NONBLOCK for the last part of file open Jens Axboe
2020-12-12 17:25 ` Al Viro
2020-12-12 17:47 ` Jens Axboe
2020-12-12 18:57 ` Linus Torvalds
2020-12-12 21:25 ` Jens Axboe
2020-12-12 22:03 ` Linus Torvalds
2020-12-13 22:50 ` Dave Chinner
2020-12-14 0:45 ` Linus Torvalds
2020-12-14 1:52 ` Dave Chinner
2020-12-14 18:06 ` Linus Torvalds
2020-12-14 17:43 ` Jens Axboe
2020-12-12 16:51 ` [PATCH 5/5] fs: expose LOOKUP_NONBLOCK through openat2() RESOLVE_NONBLOCK Jens Axboe
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=20201212165105.902688-4-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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.