This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master in repository gfs2-utils.
commit 9166d69692a15a8033a0ae5e61cbf93dc2f8ea30 Author: Andrew Price anprice@redhat.com Date: Thu Aug 3 17:08:39 2017 +0100
gfs2_grow: Remove unnecessary nesting in fix_rindex()
For readability.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/mkfs/main_grow.c | 58 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c index 10676a1..dbee4bc 100644 --- a/gfs2/mkfs/main_grow.c +++ b/gfs2/mkfs/main_grow.c @@ -262,42 +262,44 @@ static void fix_rindex(int rindex_fd, lgfs2_rgrps_t rgs, unsigned old_rg_count, char *buf; ssize_t count; ssize_t writelen; + off_t rindex_size; const size_t entrysize = sizeof(struct gfs2_rindex);
log_info( _("%d new rindex entries.\n"), rgcount); buf = rindex_buffer(rgs, rgcount); writelen = rgcount * entrysize;
- if (!test) { - off_t rindex_size = lseek(rindex_fd, 0, SEEK_END); - if (rindex_size != old_rg_count * entrysize) { - log_crit(_("Incorrect rindex size. Want %ld (%d resource groups), have %ld\n"), - (long)(old_rg_count * entrysize), old_rg_count, - (long)rindex_size); + if (test) + goto out; + + rindex_size = lseek(rindex_fd, 0, SEEK_END); + if (rindex_size != old_rg_count * entrysize) { + log_crit(_("Incorrect rindex size. Want %ld (%d resource groups), have %ld\n"), + (long)(old_rg_count * entrysize), old_rg_count, + (long)rindex_size); + goto out; + } + /* Write the first entry separately to ensure there's enough + space in the fs for the rest */ + count = write(rindex_fd, buf, entrysize); + if (count != entrysize) { + log_crit(_("Error writing first new rindex entry; aborted.\n")); + if (count > 0) + goto trunc; + else + goto out; + } + count = write(rindex_fd, (buf + entrysize), (writelen - entrysize)); + if (count != (writelen - entrysize)) { + log_crit(_("Error writing new rindex entries; aborted.\n")); + if (count > 0) + goto trunc; + else goto out; - } - /* Write the first entry separately to ensure there's enough - space in the fs for the rest */ - count = write(rindex_fd, buf, entrysize); - if (count != entrysize) { - log_crit(_("Error writing first new rindex entry; aborted.\n")); - if (count > 0) - goto trunc; - else - goto out; - } - count = write(rindex_fd, (buf + entrysize), (writelen - entrysize)); - if (count != (writelen - entrysize)) { - log_crit(_("Error writing new rindex entries; aborted.\n")); - if (count > 0) - goto trunc; - else - goto out; - } - if (fallocate(rindex_fd, FALLOC_FL_KEEP_SIZE, (rindex_size + writelen), entrysize) != 0) - perror("fallocate"); - fsync(rindex_fd); } + if (fallocate(rindex_fd, FALLOC_FL_KEEP_SIZE, (rindex_size + writelen), entrysize) != 0) + perror("fallocate"); + fsync(rindex_fd); out: free(buf); return;
cluster-commits@lists.stg.fedorahosted.org