Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292347
b: refs/heads/master
c: 82234e6
h: refs/heads/master
i:
  292345: eaa2a6c
  292343: 092a39b
v: v3
  • Loading branch information
Al Viro committed Mar 21, 2012
1 parent 68e9428 commit 6d3adb2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3ee05ed0679f29ab19727067ff7c14f0c257fa9a
refs/heads/master: 82234e61a8fc75599f29026c0805fc0cfe2a6c87
27 changes: 15 additions & 12 deletions trunk/fs/fs_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
{
struct path old_root;

path_get_longterm(path);
spin_lock(&fs->lock);
write_seqcount_begin(&fs->seq);
old_root = fs->root;
fs->root = *path;
path_get_longterm(path);
write_seqcount_end(&fs->seq);
spin_unlock(&fs->lock);
if (old_root.dentry)
Expand All @@ -45,18 +45,26 @@ void set_fs_pwd(struct fs_struct *fs, struct path *path)
{
struct path old_pwd;

path_get_longterm(path);
spin_lock(&fs->lock);
write_seqcount_begin(&fs->seq);
old_pwd = fs->pwd;
fs->pwd = *path;
path_get_longterm(path);
write_seqcount_end(&fs->seq);
spin_unlock(&fs->lock);

if (old_pwd.dentry)
path_put_longterm(&old_pwd);
}

static inline int replace_path(struct path *p, const struct path *old, const struct path *new)
{
if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
return 0;
*p = *new;
return 1;
}

void chroot_fs_refs(struct path *old_root, struct path *new_root)
{
struct task_struct *g, *p;
Expand All @@ -68,21 +76,16 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
task_lock(p);
fs = p->fs;
if (fs) {
int hits = 0;
spin_lock(&fs->lock);
write_seqcount_begin(&fs->seq);
if (fs->root.dentry == old_root->dentry
&& fs->root.mnt == old_root->mnt) {
path_get_longterm(new_root);
fs->root = *new_root;
hits += replace_path(&fs->root, old_root, new_root);
hits += replace_path(&fs->pwd, old_root, new_root);
write_seqcount_end(&fs->seq);
while (hits--) {
count++;
}
if (fs->pwd.dentry == old_root->dentry
&& fs->pwd.mnt == old_root->mnt) {
path_get_longterm(new_root);
fs->pwd = *new_root;
count++;
}
write_seqcount_end(&fs->seq);
spin_unlock(&fs->lock);
}
task_unlock(p);
Expand Down

0 comments on commit 6d3adb2

Please sign in to comment.