@@ -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
@@ -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);
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(+)