filefrag: fix fm_start in filefrag_fiemap loop
--- misc/filefrag.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
misc/filefrag.c +1 -1
@@ -239,7 +239,7 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents) n++; } - fiemap->fm_start += fm_ext[i-1 ].fe_logical + + fiemap->fm_start = fm_ext[i-1 ].fe_logical + fm_ext[i-1 ].fe_length; }while (last ==0 );
Signature · 1 line
1.6.2.GIT
Can you please provide some more details of the problem this solves.
Quoted 25 lines · Peng Tao
Signed-off-by Peng Tao <[email protected]>--- misc/filefrag.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)misc/filefrag.c +1
-1@@ -239,7 +239,7 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents) n++; } - fiemap->fm_start += fm_ext[i-1 ].fe_logical + + fiemap->fm_start = fm_ext[i-1 ].fe_logical + fm_ext[i-1 ].fe_length; }while (last ==0 );Signature · 6 lines
1.6.2.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Quoted 1 line · Andreas Dilger
Can you please provide some more details of the problem this solves.
Sorry for the late reply.
When used with -v and the targeted file has more than 144 extents(double of the length of fm_extents array provided by buf), filefrag_fiemap loops and calls fiemap ioctl() multiple times to calculate the actual number of extents in a file. Each call to fiemap ioctl() uses fm_start as the starting logical offset. The patch fixes fm_start in each loop( except for the first one) and makes the extent calculation correct for files with more that 144 extents.
To produce the problem, first run filefrag -v on a highly fragmented file. Then change the buf size in filefrag_fiemap to make it large enough to have all the extent mapped in a single loop and run filefrag -v after recompiling. The former will produce a much smaller extent count because of the false fm_start used in the loop. And the two will produce different extent output since the 145th extent.
BTW, should I resend the patch to include the above explanation?
Quoted 35 lines · Peng Tao
Quoted 21 lines
Signed-off-by Peng Tao <[email protected]>---
misc/filefrag.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)misc/filefrag.c +1
-2@@ -239,7 +239,7 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents) n++; } - fiemap->fm_start += fm_ext[i-1].fe_logical + + fiemap->fm_start = fm_ext[i-1].fe_logical + fm_ext[i-1].fe_length; } while (last == 0); --1.6.2.GIT
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlCheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Signature · 6 lines
Cheers, Bergwolf -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Peng Tao
When used with -v and the targeted file has more than 144
extents(double of the length of fm_extents array provided by buf),filefrag_fiemaploops and calls fiemapioctl()multiple times to calculate the actual number of extents in a file. Each call to fiemapioctl()usesfm_startas the starting logical offset. The patch fixesfm_startin each loop( except for the first one) and makes the extent calculation correct for files with more that 144 extents.
Quoted 8 lines
To produce the problem, first run filefrag -v on a highly fragmented file. Then change the buf size in
filefrag_fiemapto make it large enough to have all the extent mapped in a single loop and run filefrag -v after recompiling. The former will produce a much smaller extent count because of the falsefm_startused in the loop. And the two will produce different extent output since the 145th extent.BTW, should I resend the patch to include the above explanation?
Yes, please do. I verified that the code as modified (just '=') is also present in the Lustre fiemap patch, so I'm not sure how it got += there. Possibly from an older version of the patch.
Quoted 14 lines
Quoted 14 lines · Peng Tao
Quoted 13 lines
Signed-off-by Peng Tao <[email protected]>---
misc/filefrag.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)misc/filefrag.c +0
-0@@ -239,7 +239,7 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents) n++; }
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
misc/filefrag.c +1
-2- fiemap->fm_start += fm_ext[i-1].fe_logical + + fiemap->fm_start = fm_ext[i-1].fe_logical + fm_ext[i-1].fe_length; } while (last == 0); --1.6.2.GIT
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html