@@ -83,6 +83,15 @@ static struct Command commands[] = {
"filesystem sync", "<path>\n"
"Force a sync on the filesystem <path>."
},
+ { do_start_sync, 1,
+ "filesystem start-sync", "<path>\n"
+ "Start a sync on the filesystem <path>, and print the resulting\n"
+ "transaction id."
+ },
+ { do_wait_sync, 2,
+ "filesystem wait-sync", "<path> <transid>\n"
+ "Wait for the transaction <transid> on the filesystem at <path> to commit."
+ },
{ do_resize, 2,
"filesystem resize", "[+/-]<newsize>[gkm]|max <filesystem>\n"
"Resize the file system. If 'max' is passed, the filesystem\n"
@@ -548,6 +548,55 @@ int do_fssync(int argc, char **argv)
return 0;
}
+int do_start_sync(int argc, char **argv)
+{
+ int fd, res;
+ char *path = argv[1];
+ __u64 transid;
+
+ fd = open_file_or_dir(path);
+ if (fd < 0) {
+ fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+ return 12;
+ }
+
+ printf("StartSync '%s'\n", path);
+ res = ioctl(fd, BTRFS_IOC_START_SYNC, &transid);
+ close(fd);
+ if( res < 0 ){
+ fprintf(stderr, "ERROR: unable to fs-syncing '%s'\n", path);
+ return 16;
+ } else {
+ printf("transid %llu\n", (unsigned long long)transid);
+ }
+
+ return 0;
+}
+
+int do_wait_sync(int argc, char **argv)
+{
+ int fd, res;
+ char *path = argv[1];
+ __u64 transid = atoll(argv[2]);
+
+ fd = open_file_or_dir(path);
+ if (fd < 0) {
+ fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+ return 12;
+ }
+
+ printf("WaitSync '%s' transid %llu\n", path, (unsigned long long)transid);
+ res = ioctl(fd, BTRFS_IOC_WAIT_SYNC, &transid);
+ close(fd);
+ if( res < 0 ){
+ fprintf(stderr, "ERROR: unable to wait-sync on '%s' transid %llu: %s\n", path,
+ (unsigned long long)transid, strerror(errno));
+ return 16;
+ }
+
+ return 0;
+}
+
int do_scan(int argc, char **argv)
{
int i, fd;
@@ -20,6 +20,8 @@ int do_create_snap_async(int nargs, char **argv);
int do_delete_subvolume(int nargs, char **argv);
int do_create_subvol(int nargs, char **argv);
int do_fssync(int nargs, char **argv);
+int do_start_sync(int nargs, char **argv);
+int do_wait_sync(int nargs, char **argv);
int do_defrag(int argc, char **argv);
int do_show_filesystem(int nargs, char **argv);
int do_add_volume(int nargs, char **args);