* [PATCH 0/3] btrfs-progs: stat info for btrfs rescue chunk-recover
@ 2015-09-02 9:39 Zhao Lei
2015-09-02 9:39 ` [PATCH 1/3] btrfs-progs: use for loop for scan_devices Zhao Lei
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zhao Lei @ 2015-09-02 9:39 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
chunk-recover need to use many many time in scan_devices(),
and no output in screen:
# btrfs rescue chunk-recover /dev/sda6
(no output here, but need long time)
To notice user that "the command is not hang", this patch add
dynamic updated stat information in above period:
# btrfs rescue chunk-recover /dev/sda6
Scanning: DONE in dev[0], 19998441472 in dev[1], DONE in dev[2]
(until)
Scanning: DONE in dev0, DONE in dev1, DONE in dev2
Check chunks successfully with no orphans
Recover the chunk tree successfully.
Zhao Lei (3):
btrfs-progs: use for loop for scan_devices
btrfs-progs: stat info for btrfs rescue chunk-recover
btrfs-progs: Fix some spelling typo in chunk-recover.c
chunk-recover.c | 80 ++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 57 insertions(+), 23 deletions(-)
--
1.8.5.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] btrfs-progs: use for loop for scan_devices
2015-09-02 9:39 [PATCH 0/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
@ 2015-09-02 9:39 ` Zhao Lei
2015-09-02 9:39 ` [PATCH 2/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
2015-09-02 9:39 ` [PATCH 3/3] btrfs-progs: Fix some spelling typo in chunk-recover.c Zhao Lei
2 siblings, 0 replies; 4+ messages in thread
From: Zhao Lei @ 2015-09-02 9:39 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
for() is more suitable than while() in this code block.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
chunk-recover.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/chunk-recover.c b/chunk-recover.c
index 832b3b1..66a4ce6 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -871,8 +871,7 @@ static int scan_devices(struct recover_control *rc)
devidx++;
}
- i = 0;
- while (i < devidx) {
+ for (i = 0; i < devidx; i++) {
ret = pthread_join(t_scans[i], (void **)&t_rets[i]);
if (ret || t_rets[i]) {
ret = 1;
@@ -880,7 +879,6 @@ static int scan_devices(struct recover_control *rc)
cancel_to = devnr - 1;
goto out1;
}
- i++;
}
out1:
while (ret && (cancel_from <= cancel_to)) {
--
1.8.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] btrfs-progs: stat info for btrfs rescue chunk-recover
2015-09-02 9:39 [PATCH 0/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
2015-09-02 9:39 ` [PATCH 1/3] btrfs-progs: use for loop for scan_devices Zhao Lei
@ 2015-09-02 9:39 ` Zhao Lei
2015-09-02 9:39 ` [PATCH 3/3] btrfs-progs: Fix some spelling typo in chunk-recover.c Zhao Lei
2 siblings, 0 replies; 4+ messages in thread
From: Zhao Lei @ 2015-09-02 9:39 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
chunk-recover need to use many many time in scan_devices(),
and no output in screen:
# btrfs rescue chunk-recover /dev/sda6
(no output here, but need long time)
To notice user that "the command is not hang", this patch add
dynamic updated stat information in above period:
# btrfs rescue chunk-recover /dev/sda6
Scanning: DONE in dev[0], 19998441472 in dev[1], DONE in dev[2]
(until)
Scanning: DONE in dev0, DONE in dev1, DONE in dev2
Check chunks successfully with no orphans
Recover the chunk tree successfully.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
chunk-recover.c | 72 ++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 54 insertions(+), 18 deletions(-)
diff --git a/chunk-recover.c b/chunk-recover.c
index 66a4ce6..7698ee0 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -76,6 +76,7 @@ struct device_scan {
struct recover_control *rc;
struct btrfs_device *dev;
int fd;
+ u64 bytenr;
};
static struct extent_record *btrfs_new_extent_record(struct extent_buffer *eb)
@@ -766,6 +767,8 @@ static int scan_one_device(void *dev_scan_struct)
bytenr = 0;
while (1) {
+ dev_scan->bytenr = bytenr;
+
if (is_super_block_address(bytenr))
bytenr += rc->sectorsize;
@@ -832,9 +835,8 @@ static int scan_devices(struct recover_control *rc)
int *t_rets;
int devnr = 0;
int devidx = 0;
- int cancel_from = 0;
- int cancel_to = 0;
int i;
+ int all_done;
list_for_each_entry(dev, &rc->fs_devices->devices, dev_list)
devnr++;
@@ -860,30 +862,64 @@ static int scan_devices(struct recover_control *rc)
dev_scans[devidx].rc = rc;
dev_scans[devidx].dev = dev;
dev_scans[devidx].fd = fd;
- ret = pthread_create(&t_scans[devidx], NULL,
- (void *)scan_one_device,
- (void *)&dev_scans[devidx]);
- if (ret) {
- cancel_from = 0;
- cancel_to = devidx - 1;
- goto out1;
- }
+ dev_scans[devidx].bytenr = -1;
devidx++;
}
for (i = 0; i < devidx; i++) {
- ret = pthread_join(t_scans[i], (void **)&t_rets[i]);
- if (ret || t_rets[i]) {
- ret = 1;
- cancel_from = i + 1;
- cancel_to = devnr - 1;
+ ret = pthread_create(&t_scans[i], NULL,
+ (void *)scan_one_device,
+ (void *)&dev_scans[i]);
+ if (ret)
goto out1;
+
+ dev_scans[i].bytenr = 0;
+ }
+
+ while (1) {
+ all_done = 1;
+ for (i = 0; i < devidx; i++) {
+ if (dev_scans[i].bytenr == -1)
+ continue;
+ ret = pthread_tryjoin_np(t_scans[i],
+ (void **)&t_rets[i]);
+ if (ret == EBUSY) {
+ all_done = 0;
+ continue;
+ }
+ if (ret || t_rets[i]) {
+ ret = 1;
+ goto out1;
+ }
+ dev_scans[i].bytenr = -1;
+ }
+
+ printf("\rScanning: ");
+ for (i = 0; i < devidx; i++) {
+ if (dev_scans[i].bytenr == -1)
+ printf("%sDONE in dev%d",
+ i ? ", " : "", i);
+ else
+ printf("%s%llu in dev%d",
+ i ? ", " : "", dev_scans[i].bytenr, i);
}
+ /* clear chars if exist in tail */
+ printf(" ");
+ printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
+ fflush(stdout);
+
+ if (all_done) {
+ printf("\n");
+ break;
+ }
+
+ sleep(1);
}
out1:
- while (ret && (cancel_from <= cancel_to)) {
- pthread_cancel(t_scans[cancel_from]);
- cancel_from++;
+ for (i = 0; i < devidx; i++) {
+ if (dev_scans[i].bytenr == -1)
+ continue;
+ pthread_cancel(t_scans[i]);
}
out2:
free(dev_scans);
--
1.8.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] btrfs-progs: Fix some spelling typo in chunk-recover.c
2015-09-02 9:39 [PATCH 0/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
2015-09-02 9:39 ` [PATCH 1/3] btrfs-progs: use for loop for scan_devices Zhao Lei
2015-09-02 9:39 ` [PATCH 2/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
@ 2015-09-02 9:39 ` Zhao Lei
2 siblings, 0 replies; 4+ messages in thread
From: Zhao Lei @ 2015-09-02 9:39 UTC (permalink / raw)
To: linux-btrfs; +Cc: Zhao Lei
Only comment, not big issue.
And remove no-use aggument in block_group_free_all_extent().
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
chunk-recover.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/chunk-recover.c b/chunk-recover.c
index 7698ee0..d9d777a 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -259,7 +259,7 @@ again:
list_del_init(&exist->list);
free(exist);
/*
- * We must do seach again to avoid the following cache.
+ * We must do search again to avoid the following cache.
* /--old bg 1--//--old bg 2--/
* /--new bg--/
*/
@@ -2310,7 +2310,7 @@ static void validate_rebuild_chunks(struct recover_control *rc)
}
/*
- * Return 0 when succesful, < 0 on error and > 0 if aborted by user
+ * Return 0 when successful, < 0 on error and > 0 if aborted by user
*/
int btrfs_recover_chunk_tree(char *path, int verbose, int yes)
{
--
1.8.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-02 9:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-02 9:39 [PATCH 0/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
2015-09-02 9:39 ` [PATCH 1/3] btrfs-progs: use for loop for scan_devices Zhao Lei
2015-09-02 9:39 ` [PATCH 2/3] btrfs-progs: stat info for btrfs rescue chunk-recover Zhao Lei
2015-09-02 9:39 ` [PATCH 3/3] btrfs-progs: Fix some spelling typo in chunk-recover.c Zhao Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).