diff mbox

[4/4] btrfs-progs: Simplify all-subvolumn-clean condition for wait_for_subvolume_cleaning

Message ID 26cc4d36b398b1bb582532db5cd8e65019e1e812.1440597812.git.zhaolei@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Zhaolei Aug. 26, 2015, 2:03 p.m. UTC
Instead of using a dirty-subvolumn-counter in old code, this patch
turn to use a simple and direct way:
  If (not dirty-subvolumn found in current loop) {
      return all_clean;
  }

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
 cmds-subvolume.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

David Sterba Aug. 31, 2015, 3:34 p.m. UTC | #1
On Wed, Aug 26, 2015 at 10:03:39PM +0800, Zhao Lei wrote:
> Instead of using a dirty-subvolumn-counter in old code, this patch
> turn to use a simple and direct way:
>   If (not dirty-subvolumn found in current loop) {
>       return all_clean;
>   }
> 
> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>

Applied with minor modifications, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 0b398f0..20e2c01 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -67,11 +67,11 @@  static int wait_for_subvolume_cleaning(int fd, int count, u64 *ids,
 		int sleep_interval)
 {
 	int ret;
-	int remaining;
+	int dirty_cnt;
 	int i;
 
-	remaining = count;
 	while (1) {
+		dirty_cnt = 0;
 		for (i = 0; i < count; i++) {
 			if (!ids[i])
 				continue;
@@ -80,22 +80,21 @@  static int wait_for_subvolume_cleaning(int fd, int count, u64 *ids,
 				fprintf(stderr,
 					"ERROR: can't perform the search - %s\n",
 					strerror(-ret));
-				goto out;
+				return ret;
 			}
 			if (ret) {
 				printf("Subvolume id %llu is gone\n", ids[i]);
 				ids[i] = 0;
-				remaining--;
+			} else {
+				dirty_cnt++;
 			}
 		}
-		if (!remaining)
+		if (dirty_cnt == 0)
 			break;
 		sleep(sleep_interval);
 	}
 
-	ret = 0;
-out:
-	return ret;
+	return 0;
 }
 
 static const char * const subvolume_cmd_group_usage[] = {