ALSA: hda - restore BCLK M/N values when resuming HSW/BDW display controller
[deliverable/linux.git] / fs / buffer.c
index e33f8d5452ad827eb873bdb6fa446b92ae1e0c61..eba6e4f621ce0946ddccb250103656654c0844ee 100644 (file)
@@ -227,7 +227,7 @@ __find_get_block_slow(struct block_device *bdev, sector_t block)
        int all_mapped = 1;
 
        index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits);
-       page = find_get_page(bd_mapping, index);
+       page = find_get_page_flags(bd_mapping, index, FGP_ACCESSED);
        if (!page)
                goto out;
 
@@ -1366,12 +1366,13 @@ __find_get_block(struct block_device *bdev, sector_t block, unsigned size)
        struct buffer_head *bh = lookup_bh_lru(bdev, block, size);
 
        if (bh == NULL) {
+               /* __find_get_block_slow will mark the page accessed */
                bh = __find_get_block_slow(bdev, block);
                if (bh)
                        bh_lru_install(bh);
-       }
-       if (bh)
+       } else
                touch_buffer(bh);
+
        return bh;
 }
 EXPORT_SYMBOL(__find_get_block);
@@ -1483,16 +1484,27 @@ EXPORT_SYMBOL(set_bh_page);
 /*
  * Called when truncating a buffer on a page completely.
  */
+
+/* Bits that are cleared during an invalidate */
+#define BUFFER_FLAGS_DISCARD \
+       (1 << BH_Mapped | 1 << BH_New | 1 << BH_Req | \
+        1 << BH_Delay | 1 << BH_Unwritten)
+
 static void discard_buffer(struct buffer_head * bh)
 {
+       unsigned long b_state, b_state_old;
+
        lock_buffer(bh);
        clear_buffer_dirty(bh);
        bh->b_bdev = NULL;
-       clear_buffer_mapped(bh);
-       clear_buffer_req(bh);
-       clear_buffer_new(bh);
-       clear_buffer_delay(bh);
-       clear_buffer_unwritten(bh);
+       b_state = bh->b_state;
+       for (;;) {
+               b_state_old = cmpxchg(&bh->b_state, b_state,
+                                     (b_state & ~BUFFER_FLAGS_DISCARD));
+               if (b_state_old == b_state)
+                       break;
+               b_state = b_state_old;
+       }
        unlock_buffer(bh);
 }
 
This page took 0.027213 seconds and 5 git commands to generate.