X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fbuffer.c;h=456c9ab7705b0fce1f7299ee455c26614330fb34;hb=ed50d6cbc394cd0966469d3e249353c9dd1d38b9;hp=86e58b1dcd9cbbe5184289c69d5e1186a88303d4;hpb=c9e51e4180696aa67915ec5665e4ec74125565de;p=linux-2.6 diff --git a/fs/buffer.c b/fs/buffer.c index 86e58b1dcd..456c9ab770 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1730,7 +1730,6 @@ done: * The page and buffer_heads can be released at any time from * here on. */ - wbc->pages_skipped++; /* We didn't write this page */ } return err; @@ -2564,7 +2563,7 @@ int nobh_write_end(struct file *file, struct address_space *mapping, struct page *page, void *fsdata) { struct inode *inode = page->mapping->host; - struct buffer_head *head = NULL; + struct buffer_head *head = fsdata; struct buffer_head *bh; if (!PageMappedToDisk(page)) { @@ -2585,7 +2584,6 @@ int nobh_write_end(struct file *file, struct address_space *mapping, unlock_page(page); page_cache_release(page); - head = fsdata; while (head) { bh = head; head = head->b_this_page; @@ -3215,6 +3213,50 @@ static int buffer_cpu_notify(struct notifier_block *self, return NOTIFY_OK; } +/** + * bh_uptodate_or_lock: Test whether the buffer is uptodate + * @bh: struct buffer_head + * + * Return true if the buffer is up-to-date and false, + * with the buffer locked, if not. + */ +int bh_uptodate_or_lock(struct buffer_head *bh) +{ + if (!buffer_uptodate(bh)) { + lock_buffer(bh); + if (!buffer_uptodate(bh)) + return 0; + unlock_buffer(bh); + } + return 1; +} +EXPORT_SYMBOL(bh_uptodate_or_lock); + +/** + * bh_submit_read: Submit a locked buffer for reading + * @bh: struct buffer_head + * + * Returns zero on success and -EIO on error. + */ +int bh_submit_read(struct buffer_head *bh) +{ + BUG_ON(!buffer_locked(bh)); + + if (buffer_uptodate(bh)) { + unlock_buffer(bh); + return 0; + } + + get_bh(bh); + bh->b_end_io = end_buffer_read_sync; + submit_bh(READ, bh); + wait_on_buffer(bh); + if (buffer_uptodate(bh)) + return 0; + return -EIO; +} +EXPORT_SYMBOL(bh_submit_read); + void __init buffer_init(void) { int nrpages;