mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
drbd: Allow online resizing of DRBD devices while peer not reachable (needs to be explicitly forced)
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
parent
b10d96cb9c
commit
a393db6f10
@ -1371,10 +1371,9 @@ extern int is_valid_ar_handle(struct drbd_request *, sector_t);
|
||||
extern void drbd_suspend_io(struct drbd_conf *mdev);
|
||||
extern void drbd_resume_io(struct drbd_conf *mdev);
|
||||
extern char *ppsize(char *buf, unsigned long long size);
|
||||
extern sector_t drbd_new_dev_size(struct drbd_conf *,
|
||||
struct drbd_backing_dev *);
|
||||
extern sector_t drbd_new_dev_size(struct drbd_conf *, struct drbd_backing_dev *, int);
|
||||
enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew = 2 };
|
||||
extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *) __must_hold(local);
|
||||
extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, int force) __must_hold(local);
|
||||
extern void resync_after_online_grow(struct drbd_conf *);
|
||||
extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local);
|
||||
extern int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role,
|
||||
|
@ -510,7 +510,7 @@ void drbd_resume_io(struct drbd_conf *mdev)
|
||||
* Returns 0 on success, negative return values indicate errors.
|
||||
* You should call drbd_md_sync() after calling this function.
|
||||
*/
|
||||
enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev) __must_hold(local)
|
||||
enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev, int force) __must_hold(local)
|
||||
{
|
||||
sector_t prev_first_sect, prev_size; /* previous meta location */
|
||||
sector_t la_size;
|
||||
@ -541,7 +541,7 @@ enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev) __must_ho
|
||||
/* TODO: should only be some assert here, not (re)init... */
|
||||
drbd_md_set_sector_offsets(mdev, mdev->ldev);
|
||||
|
||||
size = drbd_new_dev_size(mdev, mdev->ldev);
|
||||
size = drbd_new_dev_size(mdev, mdev->ldev, force);
|
||||
|
||||
if (drbd_get_capacity(mdev->this_bdev) != size ||
|
||||
drbd_bm_capacity(mdev) != size) {
|
||||
@ -596,7 +596,7 @@ out:
|
||||
}
|
||||
|
||||
sector_t
|
||||
drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev)
|
||||
drbd_new_dev_size(struct drbd_conf *mdev, struct drbd_backing_dev *bdev, int assume_peer_has_space)
|
||||
{
|
||||
sector_t p_size = mdev->p_size; /* partner's disk size. */
|
||||
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)
|
||||
|
||||
m_size = drbd_get_max_capacity(bdev);
|
||||
|
||||
if (mdev->state.conn < C_CONNECTED && assume_peer_has_space) {
|
||||
dev_warn(DEV, "Resize while not connected was forced by the user!\n");
|
||||
p_size = m_size;
|
||||
}
|
||||
|
||||
if (p_size && m_size) {
|
||||
size = min_t(sector_t, p_size, m_size);
|
||||
} else {
|
||||
@ -965,7 +970,7 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
|
||||
|
||||
/* Prevent shrinking of consistent devices ! */
|
||||
if (drbd_md_test_flag(nbc, MDF_CONSISTENT) &&
|
||||
drbd_new_dev_size(mdev, nbc) < nbc->md.la_size_sect) {
|
||||
drbd_new_dev_size(mdev, nbc, 0) < nbc->md.la_size_sect) {
|
||||
dev_warn(DEV, "refusing to truncate a consistent device\n");
|
||||
retcode = ERR_DISK_TO_SMALL;
|
||||
goto force_diskless_dec;
|
||||
@ -1052,7 +1057,7 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
|
||||
!drbd_md_test_flag(mdev->ldev, MDF_CONNECTED_IND))
|
||||
set_bit(USE_DEGR_WFC_T, &mdev->flags);
|
||||
|
||||
dd = drbd_determin_dev_size(mdev);
|
||||
dd = drbd_determin_dev_size(mdev, 0);
|
||||
if (dd == dev_size_error) {
|
||||
retcode = ERR_NOMEM_BITMAP;
|
||||
goto force_diskless_dec;
|
||||
@ -1504,7 +1509,7 @@ static int drbd_nl_resize(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
|
||||
}
|
||||
|
||||
mdev->ldev->dc.disk_size = (sector_t)rs.resize_size;
|
||||
dd = drbd_determin_dev_size(mdev);
|
||||
dd = drbd_determin_dev_size(mdev, rs.resize_force);
|
||||
drbd_md_sync(mdev);
|
||||
put_ldev(mdev);
|
||||
if (dd == dev_size_error) {
|
||||
|
@ -2870,7 +2870,7 @@ static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
|
||||
|
||||
/* Never shrink a device with usable data during connect.
|
||||
But allow online shrinking if we are connected. */
|
||||
if (drbd_new_dev_size(mdev, mdev->ldev) <
|
||||
if (drbd_new_dev_size(mdev, mdev->ldev, 0) <
|
||||
drbd_get_capacity(mdev->this_bdev) &&
|
||||
mdev->state.disk >= D_OUTDATED &&
|
||||
mdev->state.conn < C_CONNECTED) {
|
||||
@ -2885,7 +2885,7 @@ static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
|
||||
#undef min_not_zero
|
||||
|
||||
if (get_ldev(mdev)) {
|
||||
dd = drbd_determin_dev_size(mdev);
|
||||
dd = drbd_determin_dev_size(mdev, 0);
|
||||
put_ldev(mdev);
|
||||
if (dd == dev_size_error)
|
||||
return FALSE;
|
||||
|
@ -69,6 +69,7 @@ NL_PACKET(disconnect, 6, )
|
||||
|
||||
NL_PACKET(resize, 7,
|
||||
NL_INT64( 29, T_MAY_IGNORE, resize_size)
|
||||
NL_BIT( 68, T_MAY_IGNORE, resize_force)
|
||||
)
|
||||
|
||||
NL_PACKET(syncer_conf, 8,
|
||||
|
Loading…
Reference in New Issue
Block a user