aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_nl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/drbd/drbd_nl.c')
-rw-r--r--drivers/block/drbd/drbd_nl.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 4e0726aa53b0..1292e0620663 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -510,7 +510,7 @@ void drbd_resume_io(struct drbd_conf *mdev)
510 * Returns 0 on success, negative return values indicate errors. 510 * Returns 0 on success, negative return values indicate errors.
511 * You should call drbd_md_sync() after calling this function. 511 * You should call drbd_md_sync() after calling this function.
512 */ 512 */
513enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev) __must_hold(local) 513enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev, int force) __must_hold(local)
514{ 514{
515 sector_t prev_first_sect, prev_size; /* previous meta location */ 515 sector_t prev_first_sect, prev_size; /* previous meta location */
516 sector_t la_size; 516 sector_t la_size;
@@ -541,7 +541,7 @@ enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev) __must_ho
541 /* TODO: should only be some assert here, not (re)init... */ 541 /* TODO: should only be some assert here, not (re)init... */
542 drbd_md_set_sector_offsets(mdev, mdev->ldev); 542 drbd_md_set_sector_offsets(mdev, mdev->ldev);
543 543
544 size = drbd_new_dev_size(mdev, mdev->ldev); 544 size = drbd_new_dev_size(mdev, mdev->ldev, force);
545 545
546 if (drbd_get_capacity(mdev->this_bdev) != size || 546 if (drbd_get_capacity(mdev->this_bdev) != size ||
547 drbd_bm_capacity(mdev) != size) { 547 drbd_bm_capacity(mdev) != size) {
@@ -596,7 +596,7 @@ out:
596} 596}
597 597
598sector_t 598sector_t
599drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev) 599drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev, int assume_peer_has_space)
600{ 600{
601 sector_t p_size = mdev->p_size; /* partner's disk size. */ 601 sector_t p_size = mdev->p_size; /* partner's disk size. */
602 sector_t la_size = bdev->md.la_size_sect; /* last agreed size. */ 602 sector_t la_size = bdev->md.la_size_sect; /* last agreed size. */
@@ -606,6 +606,11 @@ drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev)
606 606
607 m_size = drbd_get_max_capacity(bdev); 607 m_size = drbd_get_max_capacity(bdev);
608 608
609 if (mdev->state.conn < C_CONNECTED && assume_peer_has_space) {
610 dev_warn(DEV, "Resize while not connected was forced by the user!\n");
611 p_size = m_size;
612 }
613
609 if (p_size && m_size) { 614 if (p_size && m_size) {
610 size = min_t(sector_t, p_size, m_size); 615 size = min_t(sector_t, p_size, m_size);
611 } else { 616 } else {
@@ -965,7 +970,7 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
965 970
966 /* Prevent shrinking of consistent devices ! */ 971 /* Prevent shrinking of consistent devices ! */
967 if (drbd_md_test_flag(nbc, MDF_CONSISTENT) && 972 if (drbd_md_test_flag(nbc, MDF_CONSISTENT) &&
968 drbd_new_dev_size(mdev, nbc) < nbc->md.la_size_sect) { 973 drbd_new_dev_size(mdev, nbc, 0) < nbc->md.la_size_sect) {
969 dev_warn(DEV, "refusing to truncate a consistent device\n"); 974 dev_warn(DEV, "refusing to truncate a consistent device\n");
970 retcode = ERR_DISK_TO_SMALL; 975 retcode = ERR_DISK_TO_SMALL;
971 goto force_diskless_dec; 976 goto force_diskless_dec;
@@ -1052,7 +1057,7 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
1052 !drbd_md_test_flag(mdev->ldev, MDF_CONNECTED_IND)) 1057 !drbd_md_test_flag(mdev->ldev, MDF_CONNECTED_IND))
1053 set_bit(USE_DEGR_WFC_T, &mdev->flags); 1058 set_bit(USE_DEGR_WFC_T, &mdev->flags);
1054 1059
1055 dd = drbd_determin_dev_size(mdev); 1060 dd = drbd_determin_dev_size(mdev, 0);
1056 if (dd == dev_size_error) { 1061 if (dd == dev_size_error) {
1057 retcode = ERR_NOMEM_BITMAP; 1062 retcode = ERR_NOMEM_BITMAP;
1058 goto force_diskless_dec; 1063 goto force_diskless_dec;
@@ -1271,7 +1276,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
1271 goto fail; 1276 goto fail;
1272 } 1277 }
1273 1278
1274 if (crypto_tfm_alg_type(crypto_hash_tfm(tfm)) != CRYPTO_ALG_TYPE_SHASH) { 1279 if (!drbd_crypto_is_hash(crypto_hash_tfm(tfm))) {
1275 retcode = ERR_AUTH_ALG_ND; 1280 retcode = ERR_AUTH_ALG_ND;
1276 goto fail; 1281 goto fail;
1277 } 1282 }
@@ -1504,7 +1509,7 @@ static int drbd_nl_resize(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
1504 } 1509 }
1505 1510
1506 mdev->ldev->dc.disk_size = (sector_t)rs.resize_size; 1511 mdev->ldev->dc.disk_size = (sector_t)rs.resize_size;
1507 dd = drbd_determin_dev_size(mdev); 1512 dd = drbd_determin_dev_size(mdev, rs.resize_force);
1508 drbd_md_sync(mdev); 1513 drbd_md_sync(mdev);
1509 put_ldev(mdev); 1514 put_ldev(mdev);
1510 if (dd == dev_size_error) { 1515 if (dd == dev_size_error) {