Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / __find_get_block_slow-scale.patch
1 Index: linux/fs/buffer.c
2 ===================================================================
3 --- linux.orig/fs/buffer.c
4 +++ linux/fs/buffer.c
5 @@ -509,13 +509,18 @@ __find_get_block_slow(struct block_devic
6         struct buffer_head *head;
7         struct page *page;
8         int all_mapped = 1;
9 +       int spinlock = 0;
10  
11         index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits);
12         page = find_get_page(bd_mapping, index);
13         if (!page)
14                 goto out;
15  
16 +       if (unlikely(TestSetPageLocked(page))) {
17         spin_lock(&bd_mapping->private_lock);
18 +               spinlock = 1;
19 +       }
20 +
21         if (!page_has_buffers(page))
22                 goto out_unlock;
23         head = page_buffers(page);
24 @@ -536,7 +541,7 @@ __find_get_block_slow(struct block_devic
25          * file io on the block device and getblk.  It gets dealt with
26          * elsewhere, don't buffer_error if we had some unmapped buffers
27          */
28 -       if (all_mapped) {
29 +       if (unlikely(all_mapped)) {
30                 printk("__find_get_block_slow() failed. "
31                         "block=%llu, b_blocknr=%llu\n",
32                         (unsigned long long)block, (unsigned long long)bh->b_blocknr);
33 @@ -544,7 +549,10 @@ __find_get_block_slow(struct block_devic
34                 printk("device blocksize: %d\n", 1 << bd_inode->i_blkbits);
35         }
36  out_unlock:
37 +       if (unlikely(spinlock))
38         spin_unlock(&bd_mapping->private_lock);
39 +       else
40 +               unlock_page(page);
41         page_cache_release(page);
42  out:
43         return ret;