Commit ef5e44a6 authored by Philipp Reisner's avatar Philipp Reisner

drbd: drbd_dew_dev_size() gets the user requests disk_size as argument

Preparing RCU for disk_conf
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent a0095508
...@@ -1395,7 +1395,7 @@ extern int drbd_msg_put_info(const char *info); ...@@ -1395,7 +1395,7 @@ extern int drbd_msg_put_info(const char *info);
extern void drbd_suspend_io(struct drbd_conf *mdev); extern void drbd_suspend_io(struct drbd_conf *mdev);
extern void drbd_resume_io(struct drbd_conf *mdev); extern void drbd_resume_io(struct drbd_conf *mdev);
extern char *ppsize(char *buf, unsigned long long size); extern char *ppsize(char *buf, unsigned long long size);
extern sector_t drbd_new_dev_size(struct drbd_conf *, struct drbd_backing_dev *, int); extern sector_t drbd_new_dev_size(struct drbd_conf *, struct drbd_backing_dev *, sector_t, int);
enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew = 2 }; enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew = 2 };
extern enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local); extern enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local);
extern void resync_after_online_grow(struct drbd_conf *); extern void resync_after_online_grow(struct drbd_conf *);
......
...@@ -775,7 +775,7 @@ void drbd_resume_io(struct drbd_conf *mdev) ...@@ -775,7 +775,7 @@ void drbd_resume_io(struct drbd_conf *mdev)
enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds_flags flags) __must_hold(local) enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds_flags flags) __must_hold(local)
{ {
sector_t prev_first_sect, prev_size; /* previous meta location */ sector_t prev_first_sect, prev_size; /* previous meta location */
sector_t la_size; sector_t la_size, u_size;
sector_t size; sector_t size;
char ppb[10]; char ppb[10];
...@@ -803,7 +803,8 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds ...@@ -803,7 +803,8 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
/* TODO: should only be some assert here, not (re)init... */ /* TODO: should only be some assert here, not (re)init... */
drbd_md_set_sector_offsets(mdev, mdev->ldev); drbd_md_set_sector_offsets(mdev, mdev->ldev);
size = drbd_new_dev_size(mdev, mdev->ldev, flags & DDSF_FORCED); u_size = mdev->ldev->dc.disk_size;
size = drbd_new_dev_size(mdev, mdev->ldev, u_size, flags & DDSF_FORCED);
if (drbd_get_capacity(mdev->this_bdev) != size || if (drbd_get_capacity(mdev->this_bdev) != size ||
drbd_bm_capacity(mdev) != size) { drbd_bm_capacity(mdev) != size) {
...@@ -866,12 +867,12 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds ...@@ -866,12 +867,12 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
} }
sector_t sector_t
drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev, int assume_peer_has_space) drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev,
sector_t u_size, int assume_peer_has_space)
{ {
sector_t p_size = mdev->p_size; /* partner's disk size. */ sector_t p_size = mdev->p_size; /* partner's disk size. */
sector_t la_size = bdev->md.la_size_sect; /* last agreed size. */ sector_t la_size = bdev->md.la_size_sect; /* last agreed size. */
sector_t m_size; /* my size */ sector_t m_size; /* my size */
sector_t u_size = bdev->dc.disk_size; /* size requested by user. */
sector_t size = 0; sector_t size = 0;
m_size = drbd_get_max_capacity(bdev); m_size = drbd_get_max_capacity(bdev);
...@@ -1406,7 +1407,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) ...@@ -1406,7 +1407,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
/* Prevent shrinking of consistent devices ! */ /* Prevent shrinking of consistent devices ! */
if (drbd_md_test_flag(nbc, MDF_CONSISTENT) && if (drbd_md_test_flag(nbc, MDF_CONSISTENT) &&
drbd_new_dev_size(mdev, nbc, 0) < nbc->md.la_size_sect) { drbd_new_dev_size(mdev, nbc, nbc->dc.disk_size, 0) < nbc->md.la_size_sect) {
dev_warn(DEV, "refusing to truncate a consistent device\n"); dev_warn(DEV, "refusing to truncate a consistent device\n");
retcode = ERR_DISK_TO_SMALL; retcode = ERR_DISK_TO_SMALL;
goto force_diskless_dec; goto force_diskless_dec;
......
...@@ -3379,7 +3379,7 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi) ...@@ -3379,7 +3379,7 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
/* Never shrink a device with usable data during connect. /* Never shrink a device with usable data during connect.
But allow online shrinking if we are connected. */ But allow online shrinking if we are connected. */
if (drbd_new_dev_size(mdev, mdev->ldev, 0) < if (drbd_new_dev_size(mdev, mdev->ldev, p_usize, 0) <
drbd_get_capacity(mdev->this_bdev) && drbd_get_capacity(mdev->this_bdev) &&
mdev->state.disk >= D_OUTDATED && mdev->state.disk >= D_OUTDATED &&
mdev->state.conn < C_CONNECTED) { mdev->state.conn < C_CONNECTED) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment