Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glfs: retry 5 times to wait the meta data updated successfully #546

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions glfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,11 @@ static int tcmu_glfs_reconfig(struct tcmu_device *dev,
struct glfs_state *gfsp = tcmur_dev_get_private(dev);
struct stat st;
int ret = -EIO;
int retry = 0;

switch (cfg->type) {
case TCMULIB_CFG_DEV_SIZE:
retry:
ret = glfs_lstat(gfsp->fs, gfsp->hosts->path, &st);
if (ret) {
tcmu_dev_warn(dev, "glfs_lstat failed: %m\n");
Expand All @@ -683,6 +685,15 @@ static int tcmu_glfs_reconfig(struct tcmu_device *dev,
/* Let the targetcli command return success */
ret = 0;
} else if (st.st_size != cfg->data.dev_size) {
/*
* Retry 5 times to make sure that the size has been
* successfully updated.
*/
if (retry++ < 5) {
sleep (1);
goto retry;
}

tcmu_dev_err(dev,
"device size and backing size disagree: device %"PRId64" backing %lld\n",
cfg->data.dev_size, (long long) st.st_size);
Expand Down