Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 257367
b: refs/heads/master
c: 12ad3ab
h: refs/heads/master
i:
  257365: 84c7281
  257363: 0f34391
  257359: 06d1ae9
v: v3
  • Loading branch information
Dave Chinner authored and Al Viro committed Jul 20, 2011
1 parent 9a4f38c commit 0a62310
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 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: 09cc9fc7a7c3d872065426d7fb0f0ad6d3eb90fc
refs/heads/master: 12ad3ab66103e6582ca69c0c9de18b13487eaaef
28 changes: 1 addition & 27 deletions trunk/fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,32 +460,6 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
return ret;
}

/*
* For background writeback the caller does not have the sb pinned
* before calling writeback. So make sure that we do pin it, so it doesn't
* go away while we are writing inodes from it.
*/
static bool pin_sb_for_writeback(struct super_block *sb)
{
spin_lock(&sb_lock);
if (list_empty(&sb->s_instances)) {
spin_unlock(&sb_lock);
return false;
}

sb->s_count++;
spin_unlock(&sb_lock);

if (down_read_trylock(&sb->s_umount)) {
if (sb->s_root)
return true;
up_read(&sb->s_umount);
}

put_super(sb);
return false;
}

/*
* Write a portion of b_io inodes which belong to @sb.
*
Expand Down Expand Up @@ -585,7 +559,7 @@ void writeback_inodes_wb(struct bdi_writeback *wb,
struct inode *inode = wb_inode(wb->b_io.prev);
struct super_block *sb = inode->i_sb;

if (!pin_sb_for_writeback(sb)) {
if (!grab_super_passive(sb)) {
requeue_io(inode);
continue;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extern struct file *get_empty_filp(void);
* super.c
*/
extern int do_remount_sb(struct super_block *, int, void *, int);
extern bool grab_super_passive(struct super_block *sb);
extern void __put_super(struct super_block *sb);
extern void put_super(struct super_block *sb);
extern struct dentry *mount_fs(struct file_system_type *,
Expand Down
33 changes: 33 additions & 0 deletions trunk/fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,39 @@ static int grab_super(struct super_block *s) __releases(sb_lock)
return 0;
}

/*
* grab_super_passive - acquire a passive reference
* @s: reference we are trying to grab
*
* Tries to acquire a passive reference. This is used in places where we
* cannot take an active reference but we need to ensure that the
* superblock does not go away while we are working on it. It returns
* false if a reference was not gained, and returns true with the s_umount
* lock held in read mode if a reference is gained. On successful return,
* the caller must drop the s_umount lock and the passive reference when
* done.
*/
bool grab_super_passive(struct super_block *sb)
{
spin_lock(&sb_lock);
if (list_empty(&sb->s_instances)) {
spin_unlock(&sb_lock);
return false;
}

sb->s_count++;
spin_unlock(&sb_lock);

if (down_read_trylock(&sb->s_umount)) {
if (sb->s_root)
return true;
up_read(&sb->s_umount);
}

put_super(sb);
return false;
}

/*
* Superblock locking. We really ought to get rid of these two.
*/
Expand Down

0 comments on commit 0a62310

Please sign in to comment.