]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ovl: split ovl_want_write() into two helpers
authorAmir Goldstein <amir73il@gmail.com>
Wed, 16 Aug 2023 09:18:15 +0000 (12:18 +0300)
committerAmir Goldstein <amir73il@gmail.com>
Mon, 30 Oct 2023 22:12:57 +0000 (00:12 +0200)
ovl_get_write_access() gets write access to upper mnt without taking
freeze protection on upper sb and ovl_start_write() only takes freeze
protection on upper sb.

These helpers will be used to breakup the large ovl_want_write() scope
during copy up into finer grained freeze protection scopes.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
fs/overlayfs/overlayfs.h
fs/overlayfs/util.c

index 9817b2dcb132c2c2991b4303eb74b51124b547e7..a22de83e0a9b28da91446d36cbd67004981922f4 100644 (file)
@@ -398,6 +398,10 @@ static inline bool ovl_open_flags_need_copy_up(int flags)
 }
 
 /* util.c */
+int ovl_get_write_access(struct dentry *dentry);
+void ovl_put_write_access(struct dentry *dentry);
+void ovl_start_write(struct dentry *dentry);
+void ovl_end_write(struct dentry *dentry);
 int ovl_want_write(struct dentry *dentry);
 void ovl_drop_write(struct dentry *dentry);
 struct dentry *ovl_workdir(struct dentry *dentry);
index 4a9e7efc90aacfb1e45053c30a82b0c686f0a03d..80f20ca853442a14d927e33a3e1aef88e1d37f34 100644 (file)
 #include <linux/ratelimit.h>
 #include "overlayfs.h"
 
+/* Get write access to upper mnt - may fail if upper sb was remounted ro */
+int ovl_get_write_access(struct dentry *dentry)
+{
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
+       return mnt_get_write_access(ovl_upper_mnt(ofs));
+}
+
+/* Get write access to upper sb - may block if upper sb is frozen */
+void ovl_start_write(struct dentry *dentry)
+{
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
+       sb_start_write(ovl_upper_mnt(ofs)->mnt_sb);
+}
+
 int ovl_want_write(struct dentry *dentry)
 {
        struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
        return mnt_want_write(ovl_upper_mnt(ofs));
 }
 
+void ovl_put_write_access(struct dentry *dentry)
+{
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
+       mnt_put_write_access(ovl_upper_mnt(ofs));
+}
+
+void ovl_end_write(struct dentry *dentry)
+{
+       struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
+       sb_end_write(ovl_upper_mnt(ofs)->mnt_sb);
+}
+
 void ovl_drop_write(struct dentry *dentry)
 {
        struct ovl_fs *ofs = OVL_FS(dentry->d_sb);