diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-07-03 13:26:43 +0200 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2014-02-17 16:42:24 +0100 |
commit | b30ab7913b0a7b1d3b1091c8cb3abb1a9f1e0824 (patch) | |
tree | 308a13ddc14374d86a2874d740aa5bc17a64b54f /drivers/block/drbd/drbd_actlog.c | |
parent | 547616979372b65646d691e8dab90e850be582fe (diff) | |
download | op-kernel-dev-b30ab7913b0a7b1d3b1091c8cb3abb1a9f1e0824.zip op-kernel-dev-b30ab7913b0a7b1d3b1091c8cb3abb1a9f1e0824.tar.gz |
drbd: Rename "mdev" to "device"
sed -i -e 's:mdev:device:g'
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_actlog.c')
-rw-r--r-- | drivers/block/drbd/drbd_actlog.c | 544 |
1 files changed, 272 insertions, 272 deletions
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c index 16041f8..b33836d 100644 --- a/drivers/block/drbd/drbd_actlog.c +++ b/drivers/block/drbd/drbd_actlog.c @@ -105,24 +105,24 @@ struct update_al_work { }; -void *drbd_md_get_buffer(struct drbd_device *mdev) +void *drbd_md_get_buffer(struct drbd_device *device) { int r; - wait_event(mdev->misc_wait, - (r = atomic_cmpxchg(&mdev->md_io_in_use, 0, 1)) == 0 || - mdev->state.disk <= D_FAILED); + wait_event(device->misc_wait, + (r = atomic_cmpxchg(&device->md_io_in_use, 0, 1)) == 0 || + device->state.disk <= D_FAILED); - return r ? NULL : page_address(mdev->md_io_page); + return r ? NULL : page_address(device->md_io_page); } -void drbd_md_put_buffer(struct drbd_device *mdev) +void drbd_md_put_buffer(struct drbd_device *device) { - if (atomic_dec_and_test(&mdev->md_io_in_use)) - wake_up(&mdev->misc_wait); + if (atomic_dec_and_test(&device->md_io_in_use)) + wake_up(&device->misc_wait); } -void wait_until_done_or_force_detached(struct drbd_device *mdev, struct drbd_backing_dev *bdev, +void wait_until_done_or_force_detached(struct drbd_device *device, struct drbd_backing_dev *bdev, unsigned int *done) { long dt; @@ -134,15 +134,15 @@ void wait_until_done_or_force_detached(struct drbd_device *mdev, struct drbd_bac if (dt == 0) dt = MAX_SCHEDULE_TIMEOUT; - dt = wait_event_timeout(mdev->misc_wait, - *done || test_bit(FORCE_DETACH, &mdev->flags), dt); + dt = wait_event_timeout(device->misc_wait, + *done || test_bit(FORCE_DETACH, &device->flags), dt); if (dt == 0) { dev_err(DEV, "meta-data IO operation timed out\n"); - drbd_chk_io_error(mdev, 1, DRBD_FORCE_DETACH); + drbd_chk_io_error(device, 1, DRBD_FORCE_DETACH); } } -static int _drbd_md_sync_page_io(struct drbd_device *mdev, +static int _drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev *bdev, struct page *page, sector_t sector, int rw, int size) @@ -150,10 +150,10 @@ static int _drbd_md_sync_page_io(struct drbd_device *mdev, struct bio *bio; int err; - mdev->md_io.done = 0; - mdev->md_io.error = -ENODEV; + device->md_io.done = 0; + device->md_io.error = -ENODEV; - if ((rw & WRITE) && !test_bit(MD_NO_FUA, &mdev->flags)) + if ((rw & WRITE) && !test_bit(MD_NO_FUA, &device->flags)) rw |= REQ_FUA | REQ_FLUSH; rw |= REQ_SYNC; @@ -163,14 +163,14 @@ static int _drbd_md_sync_page_io(struct drbd_device *mdev, err = -EIO; if (bio_add_page(bio, page, size, 0) != size) goto out; - bio->bi_private = &mdev->md_io; + bio->bi_private = &device->md_io; bio->bi_end_io = drbd_md_io_complete; bio->bi_rw = rw; - if (!(rw & WRITE) && mdev->state.disk == D_DISKLESS && mdev->ldev == NULL) + if (!(rw & WRITE) && device->state.disk == D_DISKLESS && device->ldev == NULL) /* special case, drbd_md_read() during drbd_adm_attach(): no get_ldev */ ; - else if (!get_ldev_if_state(mdev, D_ATTACHING)) { + else if (!get_ldev_if_state(device, D_ATTACHING)) { /* Corresponding put_ldev in drbd_md_io_complete() */ dev_err(DEV, "ASSERT FAILED: get_ldev_if_state() == 1 in _drbd_md_sync_page_io()\n"); err = -ENODEV; @@ -178,27 +178,27 @@ static int _drbd_md_sync_page_io(struct drbd_device *mdev, } bio_get(bio); /* one bio_put() is in the completion handler */ - atomic_inc(&mdev->md_io_in_use); /* drbd_md_put_buffer() is in the completion handler */ - if (drbd_insert_fault(mdev, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) + atomic_inc(&device->md_io_in_use); /* drbd_md_put_buffer() is in the completion handler */ + if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) bio_endio(bio, -EIO); else submit_bio(rw, bio); - wait_until_done_or_force_detached(mdev, bdev, &mdev->md_io.done); + wait_until_done_or_force_detached(device, bdev, &device->md_io.done); if (bio_flagged(bio, BIO_UPTODATE)) - err = mdev->md_io.error; + err = device->md_io.error; out: bio_put(bio); return err; } -int drbd_md_sync_page_io(struct drbd_device *mdev, struct drbd_backing_dev *bdev, +int drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev *bdev, sector_t sector, int rw) { int err; - struct page *iop = mdev->md_io_page; + struct page *iop = device->md_io_page; - D_ASSERT(atomic_read(&mdev->md_io_in_use) == 1); + D_ASSERT(atomic_read(&device->md_io_in_use) == 1); BUG_ON(!bdev->md_bdev); @@ -214,7 +214,7 @@ int drbd_md_sync_page_io(struct drbd_device *mdev, struct drbd_backing_dev *bdev (unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ"); /* we do all our meta data IO in aligned 4k blocks. */ - err = _drbd_md_sync_page_io(mdev, bdev, iop, sector, rw, 4096); + err = _drbd_md_sync_page_io(device, bdev, iop, sector, rw, 4096); if (err) { dev_err(DEV, "drbd_md_sync_page_io(,%llus,%s) failed with error %d\n", (unsigned long long)sector, (rw & WRITE) ? "WRITE" : "READ", err); @@ -222,10 +222,10 @@ int drbd_md_sync_page_io(struct drbd_device *mdev, struct drbd_backing_dev *bdev return err; } -static struct bm_extent *find_active_resync_extent(struct drbd_device *mdev, unsigned int enr) +static struct bm_extent *find_active_resync_extent(struct drbd_device *device, unsigned int enr) { struct lc_element *tmp; - tmp = lc_find(mdev->resync, enr/AL_EXT_PER_BM_SECT); + tmp = lc_find(device->resync, enr/AL_EXT_PER_BM_SECT); if (unlikely(tmp != NULL)) { struct bm_extent *bm_ext = lc_entry(tmp, struct bm_extent, lce); if (test_bit(BME_NO_WRITES, &bm_ext->flags)) @@ -234,30 +234,30 @@ static struct bm_extent *find_active_resync_extent(struct drbd_device *mdev, uns return NULL; } -static struct lc_element *_al_get(struct drbd_device *mdev, unsigned int enr, bool nonblock) +static struct lc_element *_al_get(struct drbd_device *device, unsigned int enr, bool nonblock) { struct lc_element *al_ext; struct bm_extent *bm_ext; int wake; - spin_lock_irq(&mdev->al_lock); - bm_ext = find_active_resync_extent(mdev, enr); + spin_lock_irq(&device->al_lock); + bm_ext = find_active_resync_extent(device, enr); if (bm_ext) { wake = !test_and_set_bit(BME_PRIORITY, &bm_ext->flags); - spin_unlock_irq(&mdev->al_lock); + spin_unlock_irq(&device->al_lock); if (wake) - wake_up(&mdev->al_wait); + wake_up(&device->al_wait); return NULL; } if (nonblock) - al_ext = lc_try_get(mdev->act_log, enr); + al_ext = lc_try_get(device->act_log, enr); else - al_ext = lc_get(mdev->act_log, enr); - spin_unlock_irq(&mdev->al_lock); + al_ext = lc_get(device->act_log, enr); + spin_unlock_irq(&device->al_lock); return al_ext; } -bool drbd_al_begin_io_fastpath(struct drbd_device *mdev, struct drbd_interval *i) +bool drbd_al_begin_io_fastpath(struct drbd_device *device, struct drbd_interval *i) { /* for bios crossing activity log extent boundaries, * we may need to activate two extents in one go */ @@ -265,17 +265,17 @@ bool drbd_al_begin_io_fastpath(struct drbd_device *mdev, struct drbd_interval *i unsigned last = i->size == 0 ? first : (i->sector + (i->size >> 9) - 1) >> (AL_EXTENT_SHIFT-9); D_ASSERT((unsigned)(last - first) <= 1); - D_ASSERT(atomic_read(&mdev->local_cnt) > 0); + D_ASSERT(atomic_read(&device->local_cnt) > 0); /* FIXME figure out a fast path for bios crossing AL extent boundaries */ if (first != last) return false; - return _al_get(mdev, first, true); + return _al_get(device, first, true); } static -bool drbd_al_begin_io_prepare(struct drbd_device *mdev, struct drbd_interval *i) +bool drbd_al_begin_io_prepare(struct drbd_device *device, struct drbd_interval *i) { /* for bios crossing activity log extent boundaries, * we may need to activate two extents in one go */ @@ -285,19 +285,19 @@ bool drbd_al_begin_io_prepare(struct drbd_device *mdev, struct drbd_interval *i) bool need_transaction = false; D_ASSERT(first <= last); - D_ASSERT(atomic_read(&mdev->local_cnt) > 0); + D_ASSERT(atomic_read(&device->local_cnt) > 0); for (enr = first; enr <= last; enr++) { struct lc_element *al_ext; - wait_event(mdev->al_wait, - (al_ext = _al_get(mdev, enr, false)) != NULL); + wait_event(device->al_wait, + (al_ext = _al_get(device, enr, false)) != NULL); if (al_ext->lc_number != enr) need_transaction = true; } return need_transaction; } -static int al_write_transaction(struct drbd_device *mdev, bool delegate); +static int al_write_transaction(struct drbd_device *device, bool delegate); /* When called through generic_make_request(), we must delegate * activity log I/O to the worker thread: a further request @@ -311,58 +311,58 @@ static int al_write_transaction(struct drbd_device *mdev, bool delegate); /* * @delegate: delegate activity log I/O to the worker thread */ -void drbd_al_begin_io_commit(struct drbd_device *mdev, bool delegate) +void drbd_al_begin_io_commit(struct drbd_device *device, bool delegate) { bool locked = false; - BUG_ON(delegate && current == mdev->tconn->worker.task); + BUG_ON(delegate && current == device->tconn->worker.task); /* Serialize multiple transactions. * This uses test_and_set_bit, memory barrier is implicit. */ - wait_event(mdev->al_wait, - mdev->act_log->pending_changes == 0 || - (locked = lc_try_lock_for_transaction(mdev->act_log))); + wait_event(device->al_wait, + device->act_log->pending_changes == 0 || + (locked = lc_try_lock_for_transaction(device->act_log))); if (locked) { /* Double check: it may have been committed by someone else, * while we have been waiting for the lock. */ - if (mdev->act_log->pending_changes) { + if (device->act_log->pending_changes) { bool write_al_updates; rcu_read_lock(); - write_al_updates = rcu_dereference(mdev->ldev->disk_conf)->al_updates; + write_al_updates = rcu_dereference(device->ldev->disk_conf)->al_updates; rcu_read_unlock(); if (write_al_updates) - al_write_transaction(mdev, delegate); - spin_lock_irq(&mdev->al_lock); + al_write_transaction(device, delegate); + spin_lock_irq(&device->al_lock); /* FIXME if (err) we need an "lc_cancel" here; */ - lc_committed(mdev->act_log); - spin_unlock_irq(&mdev->al_lock); + lc_committed(device->act_log); + spin_unlock_irq(&device->al_lock); } - lc_unlock(mdev->act_log); - wake_up(&mdev->al_wait); + lc_unlock(device->act_log); + wake_up(&device->al_wait); } } /* * @delegate: delegate activity log I/O to the worker thread */ -void drbd_al_begin_io(struct drbd_device *mdev, struct drbd_interval *i, bool delegate) +void drbd_al_begin_io(struct drbd_device *device, struct drbd_interval *i, bool delegate) { - BUG_ON(delegate && current == mdev->tconn->worker.task); + BUG_ON(delegate && current == device->tconn->worker.task); - if (drbd_al_begin_io_prepare(mdev, i)) - drbd_al_begin_io_commit(mdev, delegate); + if (drbd_al_begin_io_prepare(device, i)) + drbd_al_begin_io_commit(device, delegate); } -int drbd_al_begin_io_nonblock(struct drbd_device *mdev, struct drbd_interval *i) +int drbd_al_begin_io_nonblock(struct drbd_device *device, struct drbd_interval *i) { - struct lru_cache *al = mdev->act_log; + struct lru_cache *al = device->act_log; /* for bios crossing activity log extent boundaries, * we may need to activate two extents in one go */ unsigned first = i->sector >> (AL_EXTENT_SHIFT-9); @@ -386,7 +386,7 @@ int drbd_al_begin_io_nonblock(struct drbd_device *mdev, struct drbd_interval *i) /* Is resync active in this area? */ for (enr = first; enr <= last; enr++) { struct lc_element *tmp; - tmp = lc_find(mdev->resync, enr/AL_EXT_PER_BM_SECT); + tmp = lc_find(device->resync, enr/AL_EXT_PER_BM_SECT); if (unlikely(tmp != NULL)) { struct bm_extent *bm_ext = lc_entry(tmp, struct bm_extent, lce); if (test_bit(BME_NO_WRITES, &bm_ext->flags)) { @@ -402,14 +402,14 @@ int drbd_al_begin_io_nonblock(struct drbd_device *mdev, struct drbd_interval *i) * this has to be successful. */ for (enr = first; enr <= last; enr++) { struct lc_element *al_ext; - al_ext = lc_get_cumulative(mdev->act_log, enr); + al_ext = lc_get_cumulative(device->act_log, enr); if (!al_ext) dev_info(DEV, "LOGIC BUG for enr=%u\n", enr); } return 0; } -void drbd_al_complete_io(struct drbd_device *mdev, struct drbd_interval *i) +void drbd_al_complete_io(struct drbd_device *device, struct drbd_interval *i) { /* for bios crossing activity log extent boundaries, * we may need to activate two extents in one go */ @@ -420,18 +420,18 @@ void drbd_al_complete_io(struct drbd_device *mdev, struct drbd_interval *i) unsigned long flags; D_ASSERT(first <= last); - spin_lock_irqsave(&mdev->al_lock, flags); + spin_lock_irqsave(&device->al_lock, flags); for (enr = first; enr <= last; enr++) { - extent = lc_find(mdev->act_log, enr); + extent = lc_find(device->act_log, enr); if (!extent) { dev_err(DEV, "al_complete_io() called on inactive extent %u\n", enr); continue; } - lc_put(mdev->act_log, extent); + lc_put(device->act_log, extent); } - spin_unlock_irqrestore(&mdev->al_lock, flags); - wake_up(&mdev->al_wait); + spin_unlock_irqrestore(&device->al_lock, flags); + wake_up(&device->al_wait); } #if (PAGE_SHIFT + 3) < (AL_EXTENT_SHIFT - BM_BLOCK_SHIFT) @@ -461,13 +461,13 @@ static unsigned int rs_extent_to_bm_page(unsigned int rs_enr) (BM_EXT_SHIFT - BM_BLOCK_SHIFT)); } -static sector_t al_tr_number_to_on_disk_sector(struct drbd_device *mdev) +static sector_t al_tr_number_to_on_disk_sector(struct drbd_device *device) { - const unsigned int stripes = mdev->ldev->md.al_stripes; - const unsigned int stripe_size_4kB = mdev->ldev->md.al_stripe_size_4k; + const unsigned int stripes = device->ldev->md.al_stripes; + const unsigned int stripe_size_4kB = device->ldev->md.al_stripe_size_4k; /* transaction number, modulo on-disk ring buffer wrap around */ - unsigned int t = mdev->al_tr_number % (mdev->ldev->md.al_size_4k); + unsigned int t = device->al_tr_number % (device->ldev->md.al_size_4k); /* ... to aligned 4k on disk block */ t = ((t % stripes) * stripe_size_4kB) + t/stripes; @@ -476,11 +476,11 @@ static sector_t al_tr_number_to_on_disk_sector(struct drbd_device *mdev) t *= 8; /* ... plus offset to the on disk position */ - return mdev->ldev->md.md_offset + mdev->ldev->md.al_offset + t; + return device->ldev->md.md_offset + device->ldev->md.al_offset + t; } static int -_al_write_transaction(struct drbd_device *mdev) +_al_write_transaction(struct drbd_device *device) { struct al_transaction_on_disk *buffer; struct lc_element *e; @@ -490,31 +490,31 @@ _al_write_transaction(struct drbd_device *mdev) unsigned crc = 0; int err = 0; - if (!get_ldev(mdev)) { + if (!get_ldev(device)) { dev_err(DEV, "disk is %s, cannot start al transaction\n", - drbd_disk_str(mdev->state.disk)); + drbd_disk_str(device->state.disk)); return -EIO; } /* The bitmap write may have failed, causing a state change. */ - if (mdev->state.disk < D_INCONSISTENT) { + if (device->state.disk < D_INCONSISTENT) { dev_err(DEV, "disk is %s, cannot write al transaction\n", - drbd_disk_str(mdev->state.disk)); - put_ldev(mdev); + drbd_disk_str(device->state.disk)); + put_ldev(device); return -EIO; } - buffer = drbd_md_get_buffer(mdev); /* protects md_io_buffer, al_tr_cycle, ... */ + buffer = drbd_md_get_buffer(device); /* protects md_io_buffer, al_tr_cycle, ... */ if (!buffer) { dev_err(DEV, "disk failed while waiting for md_io buffer\n"); - put_ldev(mdev); + put_ldev(device); return -ENODEV; } memset(buffer, 0, sizeof(*buffer)); buffer->magic = cpu_to_be32(DRBD_AL_MAGIC); - buffer->tr_number = cpu_to_be32(mdev->al_tr_number); + buffer->tr_number = cpu_to_be32(device->al_tr_number); i = 0; @@ -522,8 +522,8 @@ _al_write_transaction(struct drbd_device *mdev) * once we set the LC_LOCKED -- from drbd_al_begin_io(), * lc_try_lock_for_transaction() --, someone may still * be in the process of changing it. */ - spin_lock_irq(&mdev->al_lock); - list_for_each_entry(e, &mdev->act_log->to_be_changed, list) { + spin_lock_irq(&device->al_lock); + list_for_each_entry(e, &device->act_log->to_be_changed, list) { if (i == AL_UPDATES_PER_TRANSACTION) { i++; break; @@ -531,11 +531,11 @@ _al_write_transaction(struct drbd_device *mdev) buffer->update_slot_nr[i] = cpu_to_be16(e->lc_index); buffer->update_extent_nr[i] = cpu_to_be32(e->lc_new_number); if (e->lc_number != LC_FREE) - drbd_bm_mark_for_writeout(mdev, + drbd_bm_mark_for_writeout(device, al_extent_to_bm_page(e->lc_number)); i++; } - spin_unlock_irq(&mdev->al_lock); + spin_unlock_irq(&device->al_lock); BUG_ON(i > AL_UPDATES_PER_TRANSACTION); buffer->n_updates = cpu_to_be16(i); @@ -544,48 +544,48 @@ _al_write_transaction(struct drbd_device *mdev) buffer->update_extent_nr[i] = cpu_to_be32(LC_FREE); } - buffer->context_size = cpu_to_be16(mdev->act_log->nr_elements); - buffer->context_start_slot_nr = cpu_to_be16(mdev->al_tr_cycle); + buffer->context_size = cpu_to_be16(device->act_log->nr_elements); + buffer->context_start_slot_nr = cpu_to_be16(device->al_tr_cycle); mx = min_t(int, AL_CONTEXT_PER_TRANSACTION, - mdev->act_log->nr_elements - mdev->al_tr_cycle); + device->act_log->nr_elements - device->al_tr_cycle); for (i = 0; i < mx; i++) { - unsigned idx = mdev->al_tr_cycle + i; - extent_nr = lc_element_by_index(mdev->act_log, idx)->lc_number; + unsigned idx = device->al_tr_cycle + i; + extent_nr = lc_element_by_index(device->act_log, idx)->lc_number; buffer->context[i] = cpu_to_be32(extent_nr); } for (; i < AL_CONTEXT_PER_TRANSACTION; i++) buffer->context[i] = cpu_to_be32(LC_FREE); - mdev->al_tr_cycle += AL_CONTEXT_PER_TRANSACTION; - if (mdev->al_tr_cycle >= mdev->act_log->nr_elements) - mdev->al_tr_cycle = 0; + device->al_tr_cycle += AL_CONTEXT_PER_TRANSACTION; + if (device->al_tr_cycle >= device->act_log->nr_elements) + device->al_tr_cycle = 0; - sector = al_tr_number_to_on_disk_sector(mdev); + sector = al_tr_number_to_on_disk_sector(device); crc = crc32c(0, buffer, 4096); buffer->crc32c = cpu_to_be32(crc); - if (drbd_bm_write_hinted(mdev)) + if (drbd_bm_write_hinted(device)) err = -EIO; else { bool write_al_updates; rcu_read_lock(); - write_al_updates = rcu_dereference(mdev->ldev->disk_conf)->al_updates; + write_al_updates = rcu_dereference(device->ldev->disk_conf)->al_updates; rcu_read_unlock(); if (write_al_updates) { - if (drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE)) { + if (drbd_md_sync_page_io(device, device->ldev, sector, WRITE)) { err = -EIO; - drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR); + drbd_chk_io_error(device, 1, DRBD_META_IO_ERROR); } else { - mdev->al_tr_number++; - mdev->al_writ_cnt++; + device->al_tr_number++; + device->al_writ_cnt++; } } } - drbd_md_put_buffer(mdev); - put_ldev(mdev); + drbd_md_put_buffer(device); + put_ldev(device); return err; } @@ -594,10 +594,10 @@ _al_write_transaction(struct drbd_device *mdev) static int w_al_write_transaction(struct drbd_work *w, int unused) { struct update_al_work *aw = container_of(w, struct update_al_work, w); - struct drbd_device *mdev = w->mdev; + struct drbd_device *device = w->device; int err; - err = _al_write_transaction(mdev); + err = _al_write_transaction(device); aw->err = err; complete(&aw->event); @@ -607,63 +607,63 @@ static int w_al_write_transaction(struct drbd_work *w, int unused) /* Calls from worker context (see w_restart_disk_io()) need to write the transaction directly. Others came through generic_make_request(), those need to delegate it to the worker. */ -static int al_write_transaction(struct drbd_device *mdev, bool delegate) +static int al_write_transaction(struct drbd_device *device, bool delegate) { if (delegate) { struct update_al_work al_work; init_completion(&al_work.event); al_work.w.cb = w_al_write_transaction; - al_work.w.mdev = mdev; - drbd_queue_work_front(&mdev->tconn->sender_work, &al_work.w); + al_work.w.device = device; + drbd_queue_work_front(&device->tconn->sender_work, &al_work.w); wait_for_completion(&al_work.event); return al_work.err; } else - return _al_write_transaction(mdev); + return _al_write_transaction(device); } -static int _try_lc_del(struct drbd_device *mdev, struct lc_element *al_ext) +static int _try_lc_del(struct drbd_device *device, struct lc_element *al_ext) { int rv; - spin_lock_irq(&mdev->al_lock); + spin_lock_irq(&device->al_lock); rv = (al_ext->refcnt == 0); if (likely(rv)) - lc_del(mdev->act_log, al_ext); - spin_unlock_irq(&mdev->al_lock); + lc_del(device->act_log, al_ext); + spin_unlock_irq(&device->al_lock); return rv; } /** * drbd_al_shrink() - Removes all active extents form the activity log - * @mdev: DRBD device. + * @device: DRBD device. * * Removes all active extents form the activity log, waiting until * the reference count of each entry dropped to 0 first, of course. * - * You need to lock mdev->act_log with lc_try_lock() / lc_unlock() + * You need to lock device->act_log with lc_try_lock() / lc_unlock() */ -void drbd_al_shrink(struct drbd_device *mdev) +void drbd_al_shrink(struct drbd_device *device) { struct lc_element *al_ext; int i; - D_ASSERT(test_bit(__LC_LOCKED, &mdev->act_log->flags)); + D_ASSERT(test_bit(__LC_LOCKED, &device->act_log->flags)); - for (i = 0; i < mdev->act_log->nr_elements; i++) { - al_ext = lc_element_by_index(mdev->act_log, i); + for (i = 0; i < device->act_log->nr_elements; i++) { + al_ext = lc_element_by_index(device->act_log, i); if (al_ext->lc_number == LC_FREE) continue; - wait_event(mdev->al_wait, _try_lc_del(mdev, al_ext)); + wait_event(device->al_wait, _try_lc_del(device, al_ext)); } - wake_up(&mdev->al_wait); + wake_up(&device->al_wait); } -int drbd_initialize_al(struct drbd_device *mdev, void *buffer) +int drbd_initialize_al(struct drbd_device *device, void *buffer) { struct al_transaction_on_disk *al = buffer; - struct drbd_md *md = &mdev->ldev->md; + struct drbd_md *md = &device->ldev->md; sector_t al_base = md->md_offset + md->al_offset; int al_size_4k = md->al_stripes * md->al_stripe_size_4k; int i; @@ -674,7 +674,7 @@ int drbd_initialize_al(struct drbd_device *mdev, void *buffer) al->crc32c = cpu_to_be32(crc32c(0, al, 4096)); for (i = 0; i < al_size_4k; i++) { - int err = drbd_md_sync_page_io(mdev, mdev->ldev, al_base + i * 8, WRITE); + int err = drbd_md_sync_page_io(device, device->ldev, al_base + i * 8, WRITE); if (err) return err; } @@ -684,32 +684,32 @@ int drbd_initialize_al(struct drbd_device *mdev, void *buffer) static int w_update_odbm(struct drbd_work *w, int unused) { struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w); - struct drbd_device *mdev = w->mdev; + struct drbd_device *device = w->device; struct sib_info sib = { .sib_reason = SIB_SYNC_PROGRESS, }; - if (!get_ldev(mdev)) { + if (!get_ldev(device)) { if (__ratelimit(&drbd_ratelimit_state)) dev_warn(DEV, "Can not update on disk bitmap, local IO disabled.\n"); kfree(udw); return 0; } - drbd_bm_write_page(mdev, rs_extent_to_bm_page(udw->enr)); - put_ldev(mdev); + drbd_bm_write_page(device, rs_extent_to_bm_page(udw->enr)); + put_ldev(device); kfree(udw); - if (drbd_bm_total_weight(mdev) <= mdev->rs_failed) { - switch (mdev->state.conn) { + if (drbd_bm_total_weight(device) <= device->rs_failed) { + switch (device->state.conn) { case C_SYNC_SOURCE: case C_SYNC_TARGET: case C_PAUSED_SYNC_S: case C_PAUSED_SYNC_T: - drbd_resync_finished(mdev); + drbd_resync_finished(device); default: /* nothing to do */ break; } } - drbd_bcast_event(mdev, &sib); + drbd_bcast_event(device, &sib); return 0; } @@ -721,7 +721,7 @@ static int w_update_odbm(struct drbd_work *w, int unused) * * TODO will be obsoleted once we have a caching lru of the on disk bitmap */ -static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, +static void drbd_try_clear_on_disk_bm(struct drbd_device *device, sector_t sector, int count, int success) { struct lc_element *e; @@ -729,13 +729,13 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, unsigned int enr; - D_ASSERT(atomic_read(&mdev->local_cnt)); + D_ASSERT(atomic_read(&device->local_cnt)); /* I simply assume that a sector/size pair never crosses * a 16 MB extent border. (Currently this is true...) */ enr = BM_SECT_TO_EXT(sector); - e = lc_get(mdev->resync, enr); + e = lc_get(device->resync, enr); if (e) { struct bm_extent *ext = lc_entry(e, struct bm_extent, lce); if (ext->lce.lc_number == enr) { @@ -749,7 +749,7 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, (unsigned long long)sector, ext->lce.lc_number, ext->rs_left, ext->rs_failed, count, - drbd_conn_str(mdev->state.conn)); + drbd_conn_str(device->state.conn)); /* We don't expect to be able to clear more bits * than have been set when we originally counted @@ -757,7 +757,7 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, * Whatever the reason (disconnect during resync, * delayed local completion of an application write), * try to fix it up by recounting here. */ - ext->rs_left = drbd_bm_e_weight(mdev, enr); + ext->rs_left = drbd_bm_e_weight(device, enr); } } else { /* Normally this element should be in the cache, @@ -766,7 +766,7 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, * But maybe an application write finished, and we set * something outside the resync lru_cache in sync. */ - int rs_left = drbd_bm_e_weight(mdev, enr); + int rs_left = drbd_bm_e_weight(device, enr); if (ext->flags != 0) { dev_warn(DEV, "changing resync lce: %d[%u;%02lx]" " -> %d[%u;00]\n", @@ -783,9 +783,9 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, ext->rs_failed = success ? 0 : count; /* we don't keep a persistent log of the resync lru, * we can commit any change right away. */ - lc_committed(mdev->resync); + lc_committed(device->resync); } - lc_put(mdev->resync, &ext->lce); + lc_put(device->resync, &ext->lce); /* no race, we are within the al_lock! */ if (ext->rs_left == ext->rs_failed) { @@ -795,32 +795,32 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *mdev, sector_t sector, if (udw) { udw->enr = ext->lce.lc_number; udw->w.cb = w_update_odbm; - udw->w.mdev = mdev; - drbd_queue_work_front(&mdev->tconn->sender_work, &udw->w); + udw->w.device = device; + drbd_queue_work_front(&device->tconn->sender_work, &udw->w); } else { dev_warn(DEV, "Could not kmalloc an udw\n"); } } } else { dev_err(DEV, "lc_get() failed! locked=%d/%d flags=%lu\n", - mdev->resync_locked, - mdev->resync->nr_elements, - mdev->resync->flags); + device->resync_locked, + device->resync->nr_elements, + device->resync->flags); } } -void drbd_advance_rs_marks(struct drbd_device *mdev, unsigned long still_to_go) +void drbd_advance_rs_marks(struct drbd_device *device, unsigned long still_to_go) { unsigned long now = jiffies; - unsigned long last = mdev->rs_mark_time[mdev->rs_last_mark]; - int next = (mdev->rs_last_mark + 1) % DRBD_SYNC_MARKS; + unsigned long last = device->rs_mark_time[device->rs_last_mark]; + int next = (device->rs_last_mark + 1) % DRBD_SYNC_MARKS; if (time_after_eq(now, last + DRBD_SYNC_MARK_STEP)) { - if (mdev->rs_mark_left[mdev->rs_last_mark] != still_to_go && - mdev->state.conn != C_PAUSED_SYNC_T && - mdev->state.conn != C_PAUSED_SYNC_S) { - mdev->rs_mark_time[next] = now; - mdev->rs_mark_left[next] = still_to_go; - mdev->rs_last_mark = next; + if (device->rs_mark_left[device->rs_last_mark] != still_to_go && + device->state.conn != C_PAUSED_SYNC_T && + device->state.conn != C_PAUSED_SYNC_S) { + device->rs_mark_time[next] = now; + device->rs_mark_left[next] = still_to_go; + device->rs_last_mark = next; } } } @@ -832,7 +832,7 @@ void drbd_advance_rs_marks(struct drbd_device *mdev, unsigned long still_to_go) * called by worker on C_SYNC_TARGET and receiver on SyncSource. * */ -void __drbd_set_in_sync(struct drbd_device *mdev, sector_t sector, int size, +void __drbd_set_in_sync(struct drbd_device *device, sector_t sector, int size, const char *file, const unsigned int line) { /* Is called from worker and receiver context _only_ */ @@ -848,10 +848,10 @@ void __drbd_set_in_sync(struct drbd_device *mdev, sector_t sector, int size, return; } - if (!get_ldev(mdev)) + if (!get_ldev(device)) return; /* no disk, no metadata, no bitmap to clear bits in */ - nr_sectors = drbd_get_capacity(mdev->this_bdev); + nr_sectors = drbd_get_capacity(device->this_bdev); esector = sector + (size >> 9) - 1; if (!expect(sector < nr_sectors)) @@ -879,21 +879,21 @@ void __drbd_set_in_sync(struct drbd_device *mdev, sector_t sector, int size, * ok, (capacity & 7) != 0 sometimes, but who cares... * we count rs_{total,left} in bits, not sectors. */ - count = drbd_bm_clear_bits(mdev, sbnr, ebnr); + count = drbd_bm_clear_bits(device, sbnr, ebnr); if (count) { - drbd_advance_rs_marks(mdev, drbd_bm_total_weight(mdev)); - spin_lock_irqsave(&mdev->al_lock, flags); - drbd_try_clear_on_disk_bm(mdev, sector, count, true); - spin_unlock_irqrestore(&mdev->al_lock, flags); + drbd_advance_rs_marks(device, drbd_bm_total_weight(device)); + spin_lock_irqsave(&device->al_lock, flags); + drbd_try_clear_on_disk_bm(device, sector, count, true); + spin_unlock_irqrestore(&device->al_lock, flags); /* just wake_up unconditional now, various lc_chaged(), * lc_put() in drbd_try_clear_on_disk_bm(). */ wake_up = 1; } out: - put_ldev(mdev); + put_ldev(device); if (wake_up) - wake_up(&mdev->al_wait); + wake_up(&device->al_wait); } /* @@ -904,7 +904,7 @@ out: * called by tl_clear and drbd_send_dblock (==drbd_make_request). * so this can be _any_ process. */ -int __drbd_set_out_of_sync(struct drbd_device *mdev, sector_t sector, int size, +int __drbd_set_out_of_sync(struct drbd_device *device, sector_t sector, int size, const char *file, const unsigned int line) { unsigned long sbnr, ebnr, flags; @@ -922,10 +922,10 @@ int __drbd_set_out_of_sync(struct drbd_device *mdev, sector_t sector, int size, return 0; } - if (!get_ldev(mdev)) + if (!get_ldev(device)) return 0; /* no disk, no metadata, no bitmap to set bits in */ - nr_sectors = drbd_get_capacity(mdev->this_bdev); + nr_sectors = drbd_get_capacity(device->this_bdev); esector = sector + (size >> 9) - 1; if (!expect(sector < nr_sectors)) @@ -940,51 +940,51 @@ int __drbd_set_out_of_sync(struct drbd_device *mdev, sector_t sector, int size, /* ok, (capacity & 7) != 0 sometimes, but who cares... * we count rs_{total,left} in bits, not sectors. */ - spin_lock_irqsave(&mdev->al_lock, flags); - count = drbd_bm_set_bits(mdev, sbnr, ebnr); + spin_lock_irqsave(&device->al_lock, flags); + count = drbd_bm_set_bits(device, sbnr, ebnr); enr = BM_SECT_TO_EXT(sector); - e = lc_find(mdev->resync, enr); + e = lc_find(device->resync, enr); if (e) lc_entry(e, struct bm_extent, lce)->rs_left += count; - spin_unlock_irqrestore(&mdev->al_lock, flags); + spin_unlock_irqrestore(&device->al_lock, flags); out: - put_ldev(mdev); + put_ldev(device); return count; } static -struct bm_extent *_bme_get(struct drbd_device *mdev, unsigned int enr) +struct bm_extent *_bme_get(struct drbd_device *device, unsigned int enr) { struct lc_element *e; struct bm_extent *bm_ext; int wakeup = 0; unsigned long rs_flags; - spin_lock_irq(&mdev->al_lock); - if (mdev->resync_locked > mdev->resync->nr_elements/2) { - spin_unlock_irq(&mdev->al_lock); + spin_lock_irq(&device->al_lock); + if (device->resync_locked > device->resync->nr_elements/2) { + spin_unlock_irq(&device->al_lock); return NULL; } - e = lc_get(mdev->resync, enr); + e = lc_get(device->resync, enr); bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL; if (bm_ext) { if (bm_ext->lce.lc_number != enr) { - bm_ext->rs_left = drbd_bm_e_weight(mdev, enr); + bm_ext->rs_left = drbd_bm_e_weight(device, enr); bm_ext->rs_failed = 0; - lc_committed(mdev->resync); + lc_committed(device->resync); wakeup = 1; } if (bm_ext->lce.refcnt == 1) - mdev->resync_locked++; + device->resync_locked++; set_bit(BME_NO_WRITES, &bm_ext->flags); } - rs_flags = mdev->resync->flags; - spin_unlock_irq(&mdev->al_lock); + rs_flags = device->resync->flags; + spin_unlock_irq(&device->al_lock); if (wakeup) - wake_up(&mdev->al_wait); + wake_up(&device->al_wait); if (!bm_ext) { if (rs_flags & LC_STARVING) @@ -996,25 +996,25 @@ struct bm_extent *_bme_get(struct drbd_device *mdev, unsigned int enr) return bm_ext; } -static int _is_in_al(struct drbd_device *mdev, unsigned int enr) +static int _is_in_al(struct drbd_device *device, unsigned int enr) { int rv; - spin_lock_irq(&mdev->al_lock); - rv = lc_is_used(mdev->act_log, enr); - spin_unlock_irq(&mdev->al_lock); + spin_lock_irq(&device->al_lock); + rv = lc_is_used(device->act_log, enr); + spin_unlock_irq(&device->al_lock); return rv; } /** * drbd_rs_begin_io() - Gets an extent in the resync LRU cache and sets it to BME_LOCKED - * @mdev: DRBD device. + * @device: DRBD device. * @sector: The sector number. * * This functions sleeps on al_wait. Returns 0 on success, -EINTR if interrupted. */ -int drbd_rs_begin_io(struct drbd_device *mdev, sector_t sector) +int drbd_rs_begin_io(struct drbd_device *device, sector_t sector) { unsigned int enr = BM_SECT_TO_EXT(sector); struct bm_extent *bm_ext; @@ -1023,8 +1023,8 @@ int drbd_rs_begin_io(struct drbd_device *mdev, sector_t sector) 200 times -> 20 seconds. */ retry: - sig = wait_event_interruptible(mdev->al_wait, - (bm_ext = _bme_get(mdev, enr))); + sig = wait_event_interruptible(device->al_wait, + (bm_ext = _bme_get(device, enr))); if (sig) return -EINTR; @@ -1032,18 +1032,18 @@ retry: return 0; for (i = 0; i < AL_EXT_PER_BM_SECT; i++) { - sig = wait_event_interruptible(mdev->al_wait, - !_is_in_al(mdev, enr * AL_EXT_PER_BM_SECT + i) || + sig = wait_event_interruptible(device->al_wait, + !_is_in_al(device, enr * AL_EXT_PER_BM_SECT + i) || test_bit(BME_PRIORITY, &bm_ext->flags)); if (sig || (test_bit(BME_PRIORITY, &bm_ext->flags) && sa)) { - spin_lock_irq(&mdev->al_lock); - if (lc_put(mdev->resync, &bm_ext->lce) == 0) { + spin_lock_irq(&device->al_lock); + if (lc_put(device->resync, &bm_ext->lce) == 0) { bm_ext->flags = 0; /* clears BME_NO_WRITES and eventually BME_PRIORITY */ - mdev->resync_locked--; - wake_up(&mdev->al_wait); + device->resync_locked--; + wake_up(&device->al_wait); } - spin_unlock_irq(&mdev->al_lock); + spin_unlock_irq(&device->al_lock); if (sig) return -EINTR; if (schedule_timeout_interruptible(HZ/10)) @@ -1060,14 +1060,14 @@ retry: /** * drbd_try_rs_begin_io() - Gets an extent in the resync LRU cache, does not sleep - * @mdev: DRBD device. + * @device: DRBD device. * @sector: The sector number. * * Gets an extent in the resync LRU cache, sets it to BME_NO_WRITES, then * tries to set it to BME_LOCKED. Returns 0 upon success, and -EAGAIN * if there is still application IO going on in this area. */ -int drbd_try_rs_begin_io(struct drbd_device *mdev, sector_t sector) +int drbd_try_rs_begin_io(struct drbd_device *device, sector_t sector) { unsigned int enr = BM_SECT_TO_EXT(sector); const unsigned int al_enr = enr*AL_EXT_PER_BM_SECT; @@ -1075,8 +1075,8 @@ int drbd_try_rs_begin_io(struct drbd_device *mdev, sector_t sector) struct bm_extent *bm_ext; int i; - spin_lock_irq(&mdev->al_lock); - if (mdev->resync_wenr != LC_FREE && mdev->resync_wenr != enr) { + spin_lock_irq(&device->al_lock); + if (device->resync_wenr != LC_FREE && device->resync_wenr != enr) { /* in case you have very heavy scattered io, it may * stall the syncer undefined if we give up the ref count * when we try again and requeue. @@ -1090,28 +1090,28 @@ int drbd_try_rs_begin_io(struct drbd_device *mdev, sector_t sector) * the lc_put here... * we also have to wake_up */ - e = lc_find(mdev->resync, mdev->resync_wenr); + e = lc_find(device->resync, device->resync_wenr); bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL; if (bm_ext) { D_ASSERT(!test_bit(BME_LOCKED, &bm_ext->flags)); D_ASSERT(test_bit(BME_NO_WRITES, &bm_ext->flags)); clear_bit(BME_NO_WRITES, &bm_ext->flags); - mdev->resync_wenr = LC_FREE; - if (lc_put(mdev->resync, &bm_ext->lce) == 0) - mdev->resync_locked--; - wake_up(&mdev->al_wait); + device->resync_wenr = LC_FREE; + if (lc_put(device->resync, &bm_ext->lce) == 0) + device->resync_locked--; + wake_up(&device->al_wait); } else { dev_alert(DEV, "LOGIC BUG\n"); } } /* TRY. */ - e = lc_try_get(mdev->resync, enr); + e = lc_try_get(device->resync, enr); bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL; if (bm_ext) { if (test_bit(BME_LOCKED, &bm_ext->flags)) goto proceed; if (!test_and_set_bit(BME_NO_WRITES, &bm_ext->flags)) { - mdev->resync_locked++; + device->resync_locked++; } else { /* we did set the BME_NO_WRITES, * but then could not set BME_LOCKED, @@ -1123,13 +1123,13 @@ int drbd_try_rs_begin_io(struct drbd_device *mdev, sector_t sector) goto check_al; } else { /* do we rather want to try later? */ - if (mdev->resync_locked > mdev->resync->nr_elements-3) + if (device->resync_locked > device->resync->nr_elements-3) goto try_again; /* Do or do not. There is no try. -- Yoda */ - e = lc_get(mdev->resync, enr); + e = lc_get(device->resync, enr); bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL; if (!bm_ext) { - const unsigned long rs_flags = mdev->resync->flags; + const unsigned long rs_flags = device->resync->flags; if (rs_flags & LC_STARVING) dev_warn(DEV, "Have to wait for element" " (resync LRU too small?)\n"); @@ -1137,146 +1137,146 @@ int drbd_try_rs_begin_io(struct drbd_device *mdev, sector_t sector) goto try_again; } if (bm_ext->lce.lc_number != enr) { - bm_ext->rs_left = drbd_bm_e_weight(mdev, enr); + bm_ext->rs_left = drbd_bm_e_weight(device, enr); bm_ext->rs_failed = 0; - lc_committed(mdev->resync); - wake_up(&mdev->al_wait); + lc_committed(device->resync); + wake_up(&device->al_wait); D_ASSERT(test_bit(BME_LOCKED, &bm_ext->flags) == 0); } set_bit(BME_NO_WRITES, &bm_ext->flags); D_ASSERT(bm_ext->lce.refcnt == 1); - mdev->resync_locked++; + device->resync_locked++; goto check_al; } check_al: for (i = 0; i < AL_EXT_PER_BM_SECT; i++) { - if (lc_is_used(mdev->act_log, al_enr+i)) + if (lc_is_used(device->act_log, al_enr+i)) goto try_again; } set_bit(BME_LOCKED, &bm_ext->flags); proceed: - mdev->resync_wenr = LC_FREE; - spin_unlock_irq(&mdev->al_lock); + device->resync_wenr = LC_FREE; + spin_unlock_irq(&device->al_lock); return 0; try_again: if (bm_ext) - mdev->resync_wenr = enr; - spin_unlock_irq(&mdev->al_lock); + device->resync_wenr = enr; + spin_unlock_irq(&device->al_lock); return -EAGAIN; } -void drbd_rs_complete_io(struct drbd_device *mdev, sector_t sector) +void drbd_rs_complete_io(struct drbd_device *device, sector_t sector) { unsigned int enr = BM_SECT_TO_EXT(sector); struct lc_element *e; struct bm_extent *bm_ext; unsigned long flags; - spin_lock_irqsave(&mdev->al_lock, flags); - e = lc_find(mdev->resync, enr); + spin_lock_irqsave(&device->al_lock, flags); + e = lc_find(device->resync, enr); bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL; if (!bm_ext) { - spin_unlock_irqrestore(&mdev->al_lock, flags); + spin_unlock_irqrestore(&device->al_lock, flags); if (__ratelimit(&drbd_ratelimit_state)) dev_err(DEV, "drbd_rs_complete_io() called, but extent not found\n"); return; } if (bm_ext->lce.refcnt == 0) { - spin_unlock_irqrestore(&mdev->al_lock, flags); + spin_unlock_irqrestore(&device->al_lock, flags); dev_err(DEV, "drbd_rs_complete_io(,%llu [=%u]) called, " "but refcnt is 0!?\n", (unsigned long long)sector, enr); return; } - if (lc_put(mdev->resync, &bm_ext->lce) == 0) { + if (lc_put(device->resync, &bm_ext->lce) == 0) { bm_ext->flags = 0; /* clear BME_LOCKED, BME_NO_WRITES and BME_PRIORITY */ - mdev->resync_locked--; - wake_up(&mdev->al_wait); + device->resync_locked--; + wake_up(&device->al_wait); } - spin_unlock_irqrestore(&mdev->al_lock, flags); + spin_unlock_irqrestore(&device->al_lock, flags); } /** * drbd_rs_cancel_all() - Removes all extents from the resync LRU (even BME_LOCKED) - * @mdev: DRBD device. + * @device: DRBD device. */ -void drbd_rs_cancel_all(struct drbd_device *mdev) +void drbd_rs_cancel_all(struct drbd_device *device) { - spin_lock_irq(&mdev->al_lock); + spin_lock_irq(&device->al_lock); - if (get_ldev_if_state(mdev, D_FAILED)) { /* Makes sure ->resync is there. */ - lc_reset(mdev->resync); - put_ldev(mdev); + if (get_ldev_if_state(device, D_FAILED)) { /* Makes sure ->resync is there. */ + lc_reset(device->resync); + put_ldev(device); } - mdev->resync_locked = 0; - mdev->resync_wenr = LC_FREE; - spin_unlock_irq(&mdev->al_lock); - wake_up(&mdev->al_wait); + device->resync_locked = 0; + device->resync_wenr = LC_FREE; + spin_unlock_irq(&device->al_lock); + wake_up(&device->al_wait); } /** * drbd_rs_del_all() - Gracefully remove all extents from the resync LRU - * @mdev: DRBD device. + * @device: DRBD device. * * Returns 0 upon success, -EAGAIN if at least one reference count was * not zero. */ -int drbd_rs_del_all(struct drbd_device *mdev) +int drbd_rs_del_all(struct drbd_device *device) { struct lc_element *e; struct bm_extent *bm_ext; int i; - spin_lock_irq(&mdev->al_lock); + spin_lock_irq(&device->al_lock); - if (get_ldev_if_state(mdev, D_FAILED)) { + if (get_ldev_if_state(device, D_FAILED)) { /* ok, ->resync is there. */ - for (i = 0; i < mdev->resync->nr_elements; i++) { - e = lc_element_by_index(mdev->resync, i); + for (i = 0; i < device->resync->nr_elements; i++) { + e = lc_element_by_index(device->resync, i); bm_ext = lc_entry(e, struct bm_extent, lce); if (bm_ext->lce.lc_number == LC_FREE) continue; - if (bm_ext->lce.lc_number == mdev->resync_wenr) { + if (bm_ext->lce.lc_number == device->resync_wenr) { dev_info(DEV, "dropping %u in drbd_rs_del_all, apparently" " got 'synced' by application io\n", - mdev->resync_wenr); + device->resync_wenr); D_ASSERT(!test_bit(BME_LOCKED, &bm_ext->flags)); D_ASSERT(test_bit(BME_NO_WRITES, &bm_ext->flags)); clear_bit(BME_NO_WRITES, &bm_ext->flags); - mdev->resync_wenr = LC_FREE; - lc_put(mdev->resync, &bm_ext->lce); + device->resync_wenr = LC_FREE; + lc_put(device->resync, &bm_ext->lce); } if (bm_ext->lce.refcnt != 0) { dev_info(DEV, "Retrying drbd_rs_del_all() later. " "refcnt=%d\n", bm_ext->lce.refcnt); - put_ldev(mdev); - spin_unlock_irq(&mdev->al_lock); + put_ldev(device); + spin_unlock_irq(&device->al_lock); return -EAGAIN; } D_ASSERT(!test_bit(BME_LOCKED, &bm_ext->flags)); D_ASSERT(!test_bit(BME_NO_WRITES, &bm_ext->flags)); - lc_del(mdev->resync, &bm_ext->lce); + lc_del(device->resync, &bm_ext->lce); } - D_ASSERT(mdev->resync->used == 0); - put_ldev(mdev); + D_ASSERT(device->resync->used == 0); + put_ldev(device); } - spin_unlock_irq(&mdev->al_lock); - wake_up(&mdev->al_wait); + spin_unlock_irq(&device->al_lock); + wake_up(&device->al_wait); return 0; } /** * drbd_rs_failed_io() - Record information on a failure to resync the specified blocks - * @mdev: DRBD device. + * @device: DRBD device. * @sector: The sector number. * @size: Size of failed IO operation, in byte. */ -void drbd_rs_failed_io(struct drbd_device *mdev, sector_t sector, int size) +void drbd_rs_failed_io(struct drbd_device *device, sector_t sector, int size) { /* Is called from worker and receiver context _only_ */ unsigned long sbnr, ebnr, lbnr; @@ -1289,7 +1289,7 @@ void drbd_rs_failed_io(struct drbd_device *mdev, sector_t sector, int size) (unsigned long long)sector, size); return; } - nr_sectors = drbd_get_capacity(mdev->this_bdev); + nr_sectors = drbd_get_capacity(device->this_bdev); esector = sector + (size >> 9) - 1; if (!expect(sector < nr_sectors)) @@ -1317,21 +1317,21 @@ void drbd_rs_failed_io(struct drbd_device *mdev, sector_t sector, int size) * ok, (capacity & 7) != 0 sometimes, but who cares... * we count rs_{total,left} in bits, not sectors. */ - spin_lock_irq(&mdev->al_lock); - count = drbd_bm_count_bits(mdev, sbnr, ebnr); + spin_lock_irq(&device->al_lock); + count = drbd_bm_count_bits(device, sbnr, ebnr); if (count) { - mdev->rs_failed += count; + device->rs_failed += count; - if (get_ldev(mdev)) { - drbd_try_clear_on_disk_bm(mdev, sector, count, false); - put_ldev(mdev); + if (get_ldev(device)) { + drbd_try_clear_on_disk_bm(device, sector, count, false); + put_ldev(device); } /* just wake_up unconditional now, various lc_chaged(), * lc_put() in drbd_try_clear_on_disk_bm(). */ wake_up = 1; } - spin_unlock_irq(&mdev->al_lock); + spin_unlock_irq(&device->al_lock); if (wake_up) - wake_up(&mdev->al_wait); + wake_up(&device->al_wait); } |