OSDN Git Service

dm bufio: update last_accessed when relinking a buffer
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / md / dm-bufio.c
index 4e84095..eab64bc 100644 (file)
@@ -465,6 +465,7 @@ static void __relink_lru(struct dm_buffer *b, int dirty)
        c->n_buffers[dirty]++;
        b->list_mode = dirty;
        list_move(&b->lru_list, &c->lru[dirty]);
+       b->last_accessed = jiffies;
 }
 
 /*----------------------------------------------------------------
@@ -615,16 +616,6 @@ static void write_endio(struct bio *bio, int error)
 }
 
 /*
- * This function is called when wait_on_bit is actually waiting.
- */
-static int do_io_schedule(void *word)
-{
-       io_schedule();
-
-       return 0;
-}
-
-/*
  * Initiate a write on a dirty buffer, but don't wait for it.
  *
  * - If the buffer is not dirty, exit.
@@ -640,8 +631,7 @@ static void __write_dirty_buffer(struct dm_buffer *b,
                return;
 
        clear_bit(B_DIRTY, &b->state);
-       wait_on_bit_lock(&b->state, B_WRITING,
-                        do_io_schedule, TASK_UNINTERRUPTIBLE);
+       wait_on_bit_lock_io(&b->state, B_WRITING, TASK_UNINTERRUPTIBLE);
 
        if (!write_list)
                submit_io(b, WRITE, b->block, write_endio);
@@ -675,9 +665,9 @@ static void __make_buffer_clean(struct dm_buffer *b)
        if (!b->state)  /* fast case */
                return;
 
-       wait_on_bit(&b->state, B_READING, do_io_schedule, TASK_UNINTERRUPTIBLE);
+       wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE);
        __write_dirty_buffer(b, NULL);
-       wait_on_bit(&b->state, B_WRITING, do_io_schedule, TASK_UNINTERRUPTIBLE);
+       wait_on_bit_io(&b->state, B_WRITING, TASK_UNINTERRUPTIBLE);
 }
 
 /*
@@ -1030,7 +1020,7 @@ static void *new_read(struct dm_bufio_client *c, sector_t block,
        if (need_submit)
                submit_io(b, READ, b->block, read_endio);
 
-       wait_on_bit(&b->state, B_READING, do_io_schedule, TASK_UNINTERRUPTIBLE);
+       wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE);
 
        if (b->read_error) {
                int error = b->read_error;
@@ -1209,15 +1199,13 @@ again:
                                dropped_lock = 1;
                                b->hold_count++;
                                dm_bufio_unlock(c);
-                               wait_on_bit(&b->state, B_WRITING,
-                                           do_io_schedule,
-                                           TASK_UNINTERRUPTIBLE);
+                               wait_on_bit_io(&b->state, B_WRITING,
+                                              TASK_UNINTERRUPTIBLE);
                                dm_bufio_lock(c);
                                b->hold_count--;
                        } else
-                               wait_on_bit(&b->state, B_WRITING,
-                                           do_io_schedule,
-                                           TASK_UNINTERRUPTIBLE);
+                               wait_on_bit_io(&b->state, B_WRITING,
+                                              TASK_UNINTERRUPTIBLE);
                }
 
                if (!test_bit(B_DIRTY, &b->state) &&
@@ -1321,15 +1309,15 @@ retry:
 
        __write_dirty_buffer(b, NULL);
        if (b->hold_count == 1) {
-               wait_on_bit(&b->state, B_WRITING,
-                           do_io_schedule, TASK_UNINTERRUPTIBLE);
+               wait_on_bit_io(&b->state, B_WRITING,
+                              TASK_UNINTERRUPTIBLE);
                set_bit(B_DIRTY, &b->state);
                __unlink_buffer(b);
                __link_buffer(b, new_block, LIST_DIRTY);
        } else {
                sector_t old_block;
-               wait_on_bit_lock(&b->state, B_WRITING,
-                                do_io_schedule, TASK_UNINTERRUPTIBLE);
+               wait_on_bit_lock_io(&b->state, B_WRITING,
+                                   TASK_UNINTERRUPTIBLE);
                /*
                 * Relink buffer to "new_block" so that write_callback
                 * sees "new_block" as a block number.
@@ -1341,8 +1329,8 @@ retry:
                __unlink_buffer(b);
                __link_buffer(b, new_block, b->list_mode);
                submit_io(b, WRITE, new_block, write_endio);
-               wait_on_bit(&b->state, B_WRITING,
-                           do_io_schedule, TASK_UNINTERRUPTIBLE);
+               wait_on_bit_io(&b->state, B_WRITING,
+                              TASK_UNINTERRUPTIBLE);
                __unlink_buffer(b);
                __link_buffer(b, old_block, b->list_mode);
        }
@@ -1541,7 +1529,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
        BUG_ON(block_size < 1 << SECTOR_SHIFT ||
               (block_size & (block_size - 1)));
 
-       c = kmalloc(sizeof(*c), GFP_KERNEL);
+       c = kzalloc(sizeof(*c), GFP_KERNEL);
        if (!c) {
                r = -ENOMEM;
                goto bad_client;