Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4261
b: refs/heads/master
c: a397220
h: refs/heads/master
i:
  4259: 2670bcf
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Jul 8, 2005
1 parent e091aa4 commit b4f5187
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 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: d6afe27bfff30fbec2cca6ad5626c22f4094d770
refs/heads/master: a39722034ae37f80a1803bf781fe3fe1b03e20bc
25 changes: 17 additions & 8 deletions trunk/fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ static void free_more_memory(void)
*/
static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
{
static DEFINE_SPINLOCK(page_uptodate_lock);
unsigned long flags;
struct buffer_head *first;
struct buffer_head *tmp;
struct page *page;
int page_uptodate = 1;
Expand All @@ -536,7 +536,9 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
* two buffer heads end IO at almost the same time and both
* decide that the page is now completely done.
*/
spin_lock_irqsave(&page_uptodate_lock, flags);
first = page_buffers(page);
local_irq_save(flags);
bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
clear_buffer_async_read(bh);
unlock_buffer(bh);
tmp = bh;
Expand All @@ -549,7 +551,8 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
}
tmp = tmp->b_this_page;
} while (tmp != bh);
spin_unlock_irqrestore(&page_uptodate_lock, flags);
bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
local_irq_restore(flags);

/*
* If none of the buffers had errors and they are all
Expand All @@ -561,7 +564,8 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
return;

still_busy:
spin_unlock_irqrestore(&page_uptodate_lock, flags);
bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
local_irq_restore(flags);
return;
}

Expand All @@ -572,8 +576,8 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
void end_buffer_async_write(struct buffer_head *bh, int uptodate)
{
char b[BDEVNAME_SIZE];
static DEFINE_SPINLOCK(page_uptodate_lock);
unsigned long flags;
struct buffer_head *first;
struct buffer_head *tmp;
struct page *page;

Expand All @@ -594,7 +598,10 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
SetPageError(page);
}

spin_lock_irqsave(&page_uptodate_lock, flags);
first = page_buffers(page);
local_irq_save(flags);
bit_spin_lock(BH_Uptodate_Lock, &first->b_state);

clear_buffer_async_write(bh);
unlock_buffer(bh);
tmp = bh->b_this_page;
Expand All @@ -605,12 +612,14 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
}
tmp = tmp->b_this_page;
}
spin_unlock_irqrestore(&page_uptodate_lock, flags);
bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
local_irq_restore(flags);
end_page_writeback(page);
return;

still_busy:
spin_unlock_irqrestore(&page_uptodate_lock, flags);
bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
local_irq_restore(flags);
return;
}

Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/buffer_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ enum bh_state_bits {
BH_Dirty, /* Is dirty */
BH_Lock, /* Is locked */
BH_Req, /* Has been submitted for I/O */
BH_Uptodate_Lock,/* Used by the first bh in a page, to serialise
* IO completion of other buffers in the page
*/

BH_Mapped, /* Has a disk mapping */
BH_New, /* Disk mapping was newly created by get_block */
Expand Down

0 comments on commit b4f5187

Please sign in to comment.