Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166340
b: refs/heads/master
c: 9ecc273
h: refs/heads/master
v: v3
  • Loading branch information
Jens Axboe committed Sep 25, 2009
1 parent d0913aa commit d0b8aeb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 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: cf137307cd9827495b65e7d74ea2b610daa9898b
refs/heads/master: 9ecc2738ac2371f88dff5d48914b4e35c45203cd
46 changes: 29 additions & 17 deletions trunk/fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,17 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
return ret;
}

static void unpin_sb_for_writeback(struct super_block **psb)
{
struct super_block *sb = *psb;

if (sb) {
up_read(&sb->s_umount);
put_super(sb);
*psb = NULL;
}
}

/*
* For WB_SYNC_NONE writeback, the caller does not have the sb pinned
* before calling writeback. So make sure that we do pin it, so it doesn't
Expand All @@ -549,10 +560,19 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
* 1 if we failed.
*/
static int pin_sb_for_writeback(struct writeback_control *wbc,
struct inode *inode)
struct inode *inode, struct super_block **psb)
{
struct super_block *sb = inode->i_sb;

/*
* If this sb is already pinned, nothing more to do. If not and
* *psb is non-NULL, unpin the old one first
*/
if (sb == *psb)
return 0;
else if (*psb)
unpin_sb_for_writeback(psb);

/*
* Caller must already hold the ref for this
*/
Expand All @@ -566,7 +586,7 @@ static int pin_sb_for_writeback(struct writeback_control *wbc,
if (down_read_trylock(&sb->s_umount)) {
if (sb->s_root) {
spin_unlock(&sb_lock);
return 0;
goto pinned;
}
/*
* umounted, drop rwsem again and fall through to failure
Expand All @@ -577,24 +597,15 @@ static int pin_sb_for_writeback(struct writeback_control *wbc,
sb->s_count--;
spin_unlock(&sb_lock);
return 1;
}

static void unpin_sb_for_writeback(struct writeback_control *wbc,
struct inode *inode)
{
struct super_block *sb = inode->i_sb;

if (wbc->sync_mode == WB_SYNC_ALL)
return;

up_read(&sb->s_umount);
put_super(sb);
pinned:
*psb = sb;
return 0;
}

static void writeback_inodes_wb(struct bdi_writeback *wb,
struct writeback_control *wbc)
{
struct super_block *sb = wbc->sb;
struct super_block *sb = wbc->sb, *pin_sb = NULL;
const int is_blkdev_sb = sb_is_blkdev_sb(sb);
const unsigned long start = jiffies; /* livelock avoidance */

Expand Down Expand Up @@ -653,7 +664,7 @@ static void writeback_inodes_wb(struct bdi_writeback *wb,
if (inode_dirtied_after(inode, start))
break;

if (pin_sb_for_writeback(wbc, inode)) {
if (pin_sb_for_writeback(wbc, inode, &pin_sb)) {
requeue_io(inode);
continue;
}
Expand All @@ -662,7 +673,6 @@ static void writeback_inodes_wb(struct bdi_writeback *wb,
__iget(inode);
pages_skipped = wbc->pages_skipped;
writeback_single_inode(inode, wbc);
unpin_sb_for_writeback(wbc, inode);
if (wbc->pages_skipped != pages_skipped) {
/*
* writeback is not making progress due to locked
Expand All @@ -682,6 +692,8 @@ static void writeback_inodes_wb(struct bdi_writeback *wb,
wbc->more_io = 1;
}

unpin_sb_for_writeback(&pin_sb);

spin_unlock(&inode_lock);
/* Leave any unwritten inodes on b_io */
}
Expand Down

0 comments on commit d0b8aeb

Please sign in to comment.