Skip to content

Commit d08d3b3

Browse files
committed
ovl: split ovl_want_write() into two helpers
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 <[email protected]>
1 parent c002728 commit d08d3b3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

fs/overlayfs/overlayfs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ static inline bool ovl_open_flags_need_copy_up(int flags)
398398
}
399399

400400
/* util.c */
401+
int ovl_get_write_access(struct dentry *dentry);
402+
void ovl_put_write_access(struct dentry *dentry);
403+
void ovl_start_write(struct dentry *dentry);
404+
void ovl_end_write(struct dentry *dentry);
401405
int ovl_want_write(struct dentry *dentry);
402406
void ovl_drop_write(struct dentry *dentry);
403407
struct dentry *ovl_workdir(struct dentry *dentry);

fs/overlayfs/util.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,38 @@
1717
#include <linux/ratelimit.h>
1818
#include "overlayfs.h"
1919

20+
/* Get write access to upper mnt - may fail if upper sb was remounted ro */
21+
int ovl_get_write_access(struct dentry *dentry)
22+
{
23+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
24+
return mnt_get_write_access(ovl_upper_mnt(ofs));
25+
}
26+
27+
/* Get write access to upper sb - may block if upper sb is frozen */
28+
void ovl_start_write(struct dentry *dentry)
29+
{
30+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
31+
sb_start_write(ovl_upper_mnt(ofs)->mnt_sb);
32+
}
33+
2034
int ovl_want_write(struct dentry *dentry)
2135
{
2236
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
2337
return mnt_want_write(ovl_upper_mnt(ofs));
2438
}
2539

40+
void ovl_put_write_access(struct dentry *dentry)
41+
{
42+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
43+
mnt_put_write_access(ovl_upper_mnt(ofs));
44+
}
45+
46+
void ovl_end_write(struct dentry *dentry)
47+
{
48+
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
49+
sb_end_write(ovl_upper_mnt(ofs)->mnt_sb);
50+
}
51+
2652
void ovl_drop_write(struct dentry *dentry)
2753
{
2854
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);

0 commit comments

Comments
 (0)