Skip to content

Commit 39d3d60

Browse files
amir73ilMiklos Szeredi
authored andcommitted
ovl: introduce copy up waitqueue
The overlay sb 'copyup_wq' and overlay inode 'copying' condition variable are about to replace the upper sb rename_lock, as finer grained synchronization objects for concurrent copy up. Suggested-by: Miklos Szeredi <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent d8514d8 commit 39d3d60

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

fs/overlayfs/overlayfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ void ovl_dentry_version_inc(struct dentry *dentry);
178178
u64 ovl_dentry_version_get(struct dentry *dentry);
179179
bool ovl_is_whiteout(struct dentry *dentry);
180180
struct file *ovl_path_open(struct path *path, int flags);
181+
int ovl_copy_up_start(struct dentry *dentry);
182+
void ovl_copy_up_end(struct dentry *dentry);
181183

182184
/* namei.c */
183185
int ovl_path_next(int idx, struct dentry *dentry, struct path *path);

fs/overlayfs/ovl_entry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct ovl_fs {
2828
/* creds of process who forced instantiation of super block */
2929
const struct cred *creator_cred;
3030
bool tmpfile;
31+
wait_queue_head_t copyup_wq;
3132
};
3233

3334
/* private information held for every overlayfs dentry */
@@ -39,6 +40,7 @@ struct ovl_entry {
3940
u64 version;
4041
const char *redirect;
4142
bool opaque;
43+
bool copying;
4244
};
4345
struct rcu_head rcu;
4446
};

fs/overlayfs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
708708
if (!ufs)
709709
goto out;
710710

711+
init_waitqueue_head(&ufs->copyup_wq);
711712
ufs->config.redirect_dir = ovl_redirect_dir_def;
712713
err = ovl_parse_opt((char *) data, &ufs->config);
713714
if (err)

fs/overlayfs/util.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,33 @@ struct file *ovl_path_open(struct path *path, int flags)
263263
{
264264
return dentry_open(path, flags | O_NOATIME, current_cred());
265265
}
266+
267+
int ovl_copy_up_start(struct dentry *dentry)
268+
{
269+
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
270+
struct ovl_entry *oe = dentry->d_fsdata;
271+
int err;
272+
273+
spin_lock(&ofs->copyup_wq.lock);
274+
err = wait_event_interruptible_locked(ofs->copyup_wq, !oe->copying);
275+
if (!err) {
276+
if (oe->__upperdentry)
277+
err = 1; /* Already copied up */
278+
else
279+
oe->copying = true;
280+
}
281+
spin_unlock(&ofs->copyup_wq.lock);
282+
283+
return err;
284+
}
285+
286+
void ovl_copy_up_end(struct dentry *dentry)
287+
{
288+
struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
289+
struct ovl_entry *oe = dentry->d_fsdata;
290+
291+
spin_lock(&ofs->copyup_wq.lock);
292+
oe->copying = false;
293+
wake_up_locked(&ofs->copyup_wq);
294+
spin_unlock(&ofs->copyup_wq.lock);
295+
}

0 commit comments

Comments
 (0)