adding Btrfs resizing capability to lvresize/fsadm.sh
cover adding Btrfs resizing capability to lvresize/fsadm.sh
Btrfs support was missing from LVM's volume resize tools. Fixed that.
Marcus M?ller (1):
added resizing for btrfs
scripts/fsadm.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)
Signature · 1 line
2.13.0
PATCH 1/1 added resizing for btrfs
From: Marcus M?ller <[email protected]>
--- scripts/fsadm.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)
scripts/fsadm.sh +68 -1
@@ -22,6 +22,7 @@ # ext2/ext3/ext4: resize2fs, tune2fs # reiserfs: resize_reiserfs, reiserfstune # xfs: xfs_growfs, xfs_info +# btrfs: btrfs # # Return values: # 0 success
@@ -41,6 +42,7 @@ TUNE_REISER=reiserfstune RESIZE_REISER=resize_reiserfs TUNE_XFS=xfs_info RESIZE_XFS=xfs_growfs +TOOL_BTRFS=btrfs MOUNT=mount UMOUNT=umount
@@ -520,6 +522,70 @@ resize_xfs() { fi } +############################################################################### +# Resize BTRFS filesystem +# - mounted for upsize +# - mounted for downsize +# - since BTRFS supports multi-volume filesystems, only resize the btrfs volume +# we've actually resized +############################################################################### +resize_btrfs() { + detect_mounted + MOUNTPOINT=$MOUNTED + if [ -z "$MOUNTED" ]; then + MOUNTPOINT=$TEMPDIR + temp_mount || error "Cannot mount Btrfs filesystem." + fi + verbose "mounted on $MOUNTPOINT" + + local old_ifs="$IFS" + local last_line="" + local used="" + local devid="" + local devid_use="" + BLOCKSIZE=1 + + unset IFS + verbose "Parsing $TOOL_BTRFS filesystem show --raw \"$VOLUME\"" + for i in $(LC_ALL=C "$TOOL_BTRFS" filesystem show --raw "$VOLUME"); do + case "$last_line" in + "size") + BLOCKCOUNT=$i + ;; + "used") + used=$i + ;; + "devid") + devid="$i" + ;; + "path") + if test "$i" = "$VOLUME" ; then + verbose "Found $VOLUME; has devid $devid size $BLOCKCOUNT B" + devid_use="$devid" + fi + ;; + esac + + line_before="$last_line" + last_line="$i" + done + IFS=old_ifs + + + validate_parsing "$TOOL_BTRFS" + decode_size "$BLOCKCOUNT" "$BLOCKSIZE" + FSFORCE=$FORCE + if test $(("$used")) -lt $(("$NEWSIZE")) ; then + verbose "$VOLUME: size $NEWSIZE B >= used $used B" + else + verbose "$VOLUME: trying to shrink filesystem to size $NEWSIZE B, which is less than used $used B" + verbose "$VOLUME: that might still work on multi-volume Btrfs" + fi + verbose "Resizing filesystem on device \"$VOLUME\", mounted on \"$MOUNTPOINT\" to $NEWSIZE bytes" + dry "$TOOL_BTRFS" filesystem resize "${devid_use}:${NEWSIZE}" "$MOUNTPOINT" + +} + #################### # Resize filesystem ####################
@@ -536,6 +602,7 @@ resize() { "ext3"|"ext2"|"ext4") resize_ext $NEWSIZE ;; "reiserfs") resize_reiser $NEWSIZE ;; "xfs") resize_xfs $NEWSIZE ;; + "btrfs") resize_btrfs $NEWSIZE ;; *) error "Filesystem \"$FSTYPE\" on device \"$VOLUME\" is not supported by this tool." ;; esac || error "Resize $FSTYPE failed." cleanup 0
@@ -612,7 +679,7 @@ test -n "$FSADM_RUNNING" && exit 0 # test some prerequisities for i in "$TUNE_EXT" "$RESIZE_EXT" "$TUNE_REISER" "$RESIZE_REISER" \ - "$TUNE_XFS" "$RESIZE_XFS" "$MOUNT" "$UMOUNT" "$MKDIR" \ + "$TUNE_XFS" "$RESIZE_XFS" "$TOOL_BTRFS" "$MOUNT" "$UMOUNT" "$MKDIR" \ "$RMDIR" "$BLOCKDEV" "$BLKID" "$GREP" "$READLINK" \ "$DATE" "$FSCK" "$XFS_CHECK" "$XFS_REPAIR" "$LVM" ; do test -n "$i" || error "Required command definitions in the script are missing!"
Signature · 1 line
2.13.0
cover adding Btrfs resizing capability to lvresize/fsadm.sh
In reply to Marcus MüllerSo,
I'll admit that me spontaneously handing in above feature patch yesterday was an act of "let's get this out of my head before I go home". For private purposes, I wanted lvresize -r to deal with BTRFS, too. Am I right here to post feature branches at all? Any copyright assignments I need to take care of?
Regarding the patch:
BTRFS is a bit special in that one filesystem can spread across multiple physical volumes. In the case of multi-volume BTRFS, we need to specify which specific one needs resizing; hence the whole devid dance.
Also: BTRFS needs to be mounted to be resized; mount detection sometimes fails. That is not an issue, since it's safe to multi-mount a filesystem and resize it. So in fact, I was considering skipping the checking for mountedness completely, but then decided against it to keep the resize_* functions as uniform and recognizable as possible.
Best regards,
Marcus M?ller
Quoted 9 lines · Marcus M?ller
Btrfs support was missing from LVM's volume resize tools. Fixed that.
Marcus M?ller (1):
added resizing for btrfsscripts/fsadm.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)
cover adding Btrfs resizing capability to lvresize/fsadm.sh
Hi,
openSUSE has a similar patch [1] for a while. The original author sent it upstream I think,
but for whatever reason, it was not accepted.
fsadm-add-support-for-btrfs.patch
[1]
https://build.opensuse.org/package/view_file/Base:System/lvm2/fsadm-add-support-for-btrfs.patch?expand=1
@Upstream experts, please let me know if you are open to merge this patch. If so, I can give a close review and testing on it. I'd like see your patch to be accepted.
Then, I can drop our own patch ;-P
Regards,
Eric
Quoted 36 lines · Marcus M?ller
So,
I'll admit that me spontaneously handing in above feature patch yesterday was an act of "let's get this out of my head before I go home". For private purposes, I wanted lvresize -r to deal with BTRFS, too. Am I right here to post feature branches at all? Any copyright assignments I need to take care of?
Regarding the patch:
BTRFS is a bit special in that one filesystem can spread across multiple physical volumes. In the case of multi-volume BTRFS, we need to specify which specific one needs resizing; hence the whole devid dance.
Also: BTRFS needs to be mounted to be resized; mount detection sometimes fails. That is not an issue, since it's safe to multi-mount a filesystem and resize it. So in fact, I was considering skipping the checking for mountedness completely, but then decided against it to keep the resize_* functions as uniform and recognizable as possible.Best regards,
Marcus M?llerQuoted 9 lines · Marcus M?ller
Btrfs support was missing from LVM's volume resize tools. Fixed that.
Marcus M?ller (1):
added resizing for btrfsscripts/fsadm.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)--
lvm-devel mailing list
lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel
cover adding Btrfs resizing capability to lvresize/fsadm.sh
Dne 4.8.2017 v 09:13 Eric Ren napsal(a):
Quoted 16 lines
Hi,
openSUSE has a similar patch [1] for a while. The original author sent it upstream I think,
but for whatever reason, it was not accepted.fsadm-add-support-for-btrfs.patch
[1]
https://build.opensuse.org/package/view_file/Base:System/lvm2/fsadm-add-support-for-btrfs.patch?expand=1@Upstream experts, please let me know if you are open to merge this patch. If so, I can give a close review and testing on it. I'd like see your patch to be accepted.
Then, I can drop our own patch ;-P
Quoted 12 lines
Regards,
EricQuoted 8 lines · Marcus M?ller
So,
I'll admit that me spontaneously handing in above feature patch yesterday was an act of "let's get this out of my head before I go home". For private purposes, I wanted lvresize -r to deal with BTRFS, too. Am I right here to post feature branches at all? Any copyright assignments I need to take care of?
Hi
From my memory - when we tried to use such patch in past - we've found too
many rough edges on anything btrfs related.
I'm not an expert of btrfs at all - but we noticed lot of troubles in terms of btrfs was not even noticing it has got smaller, disk got missing and many other conditions.
So to get such 'btrfs resize' patch accepted - it MUST be equipped with lvm2 test suite script - possibly with a new separate test file (so it's not mixed with already complex test/shell/fsadm.sh)
It should test fair amount of condition - so we can be at least partially sure 'fsadm' will not totally mess users data just because it has run command on some unexpected variants of 'btrfs' disk layout.
In fact it should check for 'known layout' and only let proceed with
command on this path (including for checking minimal version
of kernel and btrfs-tools where btrfs is known to be stable enough for this operation.
I do believe that format of /test/shell/*sh is relatively readable. For running the test -
do your lvm2 build and then within subdir /test/ run something like:
'make check_local T=fsadm-btrfs.sh VERBOSE=1'
to check the tool is doing something useful.
If something is unclear - feel free to reach me on freenode #lvm channel to get this working properly.
Regards
Zdenek
cover adding Btrfs resizing capability to lvresize/fsadm.sh
Hi Zdenek and Marcus,
Quoted 29 lines · Zdenek Kabelac
[...snip...]
Hi
From my memory - when we tried to use such patch in past - we've found too many rough edges on anything btrfs related.
I'm not an expert of btrfs at all - but we noticed lot of troubles in terms
of btrfs was not even noticing it has got smaller, disk got missing and many other conditions.So to get such 'btrfs resize' patch accepted - it MUST be equipped with lvm2 test suite script - possibly with a new separate test file (so it's not mixed with already complex
test/shell/fsadm.sh)It should test fair amount of condition - so we can be at least partially sure 'fsadm' will not totally mess users data just because it has run command on some unexpected variants of 'btrfs' disk layout.
In fact it should check for 'known layout' and only let proceed with
command on this path (including for checking minimal version
of kernel and btrfs-tools where btrfs is known to be stable enough for this operation.I do believe that format of /test/shell/*sh is relatively readable. For running the test -
Quoted 7 lines
do your lvm2 build and then within subdir /test/ run something like:
'make
check_localT=fsadm-btrfs.sh VERBOSE=1'to check the tool is doing something useful.
If something is unclear - feel free to reach me on freenode #lvm channel to get this working properly.
Thanks for your detailed feedback!
I can try to write such a testcase, and ask you
for review when it's finished ;-)
Cheers,
Eric
Quoted 5 lines
Regards
Zdenek
cover adding Btrfs resizing capability to lvresize/fsadm.sh
Hi Zdenek,
Thank you for the extensive explanation! I do agree, in this context, unverified functionality might be worse than none :)
Hi Eric,
Please do! And: please don't hesitate to ask for feedback of even better assistance if necessary - you're solving my problems, I'd like to help you with that.
Best regards,
Marcus
Quoted 59 lines · Eric Ren
Hi Zdenek and Marcus,
Quoted 5 lines · Zdenek Kabelac
[...snip...]
Hi
From my memory - when we tried to use such patch in past - we've
found
Quoted 9 lines
too many rough edges on anything btrfs related.
I'm not an expert of btrfs at all - but we noticed lot of troubles in
terms
of btrfs was not even noticing it has got smaller, disk got missing and many other conditions.So to get such 'btrfs resize' patch accepted - it MUST be equipped
with
Quoted 4 lines
lvm2 test suite script - possibly with a new separate test file (so it's not mixed with already complex
test/shell/fsadm.sh)It should test fair amount of condition - so we can be at least
partially
Quoted 1 line
sure 'fsadm' will not totally mess users data just because it has
run
Quoted 5 lines
command on some unexpected variants of 'btrfs' disk layout.
In fact it should check for 'known layout' and only let proceed with
command on this path (including for checking minimal version
of kernel and btrfs-tools where btrfs is known to be stable enoughfor
Quoted 6 lines
this operation.
I do believe that format of /test/shell/*sh is relatively readable. For running the test -
Quoted 6 lines
do your lvm2 build and then within subdir /test/ run something like:
'make
check_localT=fsadm-btrfs.sh VERBOSE=1'to check the tool is doing something useful.
If something is unclear - feel free to reach me on freenode #lvmchannel
Quoted 1 line
to get this working properly.
Thanks for your detailed feedback!
I can try to write such a testcase, and ask you
for review when it's finished ;-)Cheers,
EricQuoted 5 lines
Regards
Zdenek
Signature · 4 lines
Sent from my Android device with K-9 Mail. Please excuse my brevity. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20170814/342c06a3/attachment.htm>
PATCH 1/1 added resizing for btrfs
In reply to Marcus MüllerHi Marcus,
I draft a test script [2] for this patch. I've tested our SUSE-specific patch[1] with this test script.
But, I haven't test your patch yet.
I find two things in your patch, hope you can take another look:
1. lack "check" action in your script
In patch [1], it uses "btrfs scrub", which I think you can replace it with "btrfs check".
2. some review comments inline below.
[1] 0001-fsadm-add-support-for-btrfs.patch
[2] 0002-test-add-fsadm-btrfs.sh.patch
Quoted 35 lines · c M?ller
From: Marcus M?ller <[email protected]>
--- scripts/fsadm.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)scripts/fsadm.sh +7
-0@@ -22,6 +22,7 @@ # ext2/ext3/ext4: resize2fs, tune2fs # reiserfs: resize_reiserfs, reiserfstune # xfs: xfs_growfs, xfs_info +# btrfs: btrfs # # Return values: # 0 success@@ -41,6 +42,7 @@ TUNE_REISER=reiserfstune RESIZE_REISER=resize_reiserfs TUNE_XFS=xfs_info RESIZE_XFS=xfs_growfs +TOOL_BTRFS=btrfs MOUNT=mount UMOUNT=umount@@ -520,6 +522,70 @@ resize_xfs() { fi } +############################################################################### +# Resize BTRFS filesystem +# - mounted for upsize +# - mounted for downsize +# - since BTRFS supports multi-volume filesystems, only resize the btrfs volume
scripts/fsadm.sh resize_xfs() { · line 539
Quoted 10 lines
scripts/fsadm.sh +10
-0+# we've actually resized +############################################################################### +resize_btrfs() { + detect_mounted + MOUNTPOINT=$MOUNTED + if [ -z "$MOUNTED" ]; then + MOUNTPOINT=$TEMPDIR + temp_mount || error "Cannot mount Btrfs filesystem." + fi + verbose "mounted on $MOUNTPOINT"
Indention looks wrong?
Verbose like "$subvolume mounted on $mnt"?
Quoted 21 lines
scripts/fsadm.sh +21
-0+ + local old_ifs="$IFS" + local last_line="" + local used="" + local devid="" + local devid_use="" + BLOCKSIZE=1 + + unset IFS + verbose "Parsing $TOOL_BTRFS filesystem show --raw \"$VOLUME\"" + for i in $(LC_ALL=C "$TOOL_BTRFS" filesystem show --raw "$VOLUME"); do + case "$last_line" in + "size") + BLOCKCOUNT=$i + ;; + "used") + used=$i + ;; + "devid") + devid="$i" + ;;
scripts/fsadm.sh resize_xfs() { · line 570
Quoted 10 lines
scripts/fsadm.sh +10
-0+ "path") + if test "$i" = "$VOLUME" ; then + verbose "Found $VOLUME; has devid $devid size $BLOCKCOUNT B" + devid_use="$devid" + fi + ;; + esac + + line_before="$last_line" + last_line="$i"
There variables "line_before" and "last_line" look redundant?
Thanks,
Eric
Quoted 30 lines
scripts/fsadm.sh +19
-0+ done + IFS=old_ifs + + + validate_parsing "$TOOL_BTRFS" + decode_size "$BLOCKCOUNT" "$BLOCKSIZE" + FSFORCE=$FORCE + if test $(("$used")) -lt $(("$NEWSIZE")) ; then + verbose "$VOLUME: size $NEWSIZE B >= used $used B" + else + verbose "$VOLUME: trying to shrink filesystem to size $NEWSIZE B, which is less than used $used B" + verbose "$VOLUME: that might still work on multi-volume Btrfs" + fi + verbose "Resizing filesystem on device \"$VOLUME\", mounted on \"$MOUNTPOINT\" to $NEWSIZE bytes" + dry "$TOOL_BTRFS" filesystem resize "${devid_use}:${NEWSIZE}" "$MOUNTPOINT" + +} + #################### # Resize filesystem ####################@@ -536,6 +602,7 @@ resize() { "ext3"|"ext2"|"ext4") resize_ext $NEWSIZE ;; "reiserfs") resize_reiser $NEWSIZE ;; "xfs") resize_xfs $NEWSIZE ;; + "btrfs") resize_btrfs $NEWSIZE ;; *) error "Filesystem \"$FSTYPE\" on device \"$VOLUME\" is not supported by this tool." ;; esac || error "Resize $FSTYPE failed." cleanup 0
scripts/fsadm.sh test -n "$FSADM_RUNNING" && exit 0 · line 685
Quoted 8 lines
scripts/fsadm.sh +1
-1@@ -612,7 +679,7 @@ test -n "$FSADM_RUNNING" && exit 0 # test some prerequisities for i in "$TUNE_EXT" "$RESIZE_EXT" "$TUNE_REISER" "$RESIZE_REISER" \ - "$TUNE_XFS" "$RESIZE_XFS" "$MOUNT" "$UMOUNT" "$MKDIR" \ + "$TUNE_XFS" "$RESIZE_XFS" "$TOOL_BTRFS" "$MOUNT" "$UMOUNT" "$MKDIR" \ "$RMDIR" "$BLOCKDEV" "$BLKID" "$GREP" "$READLINK" \ "$DATE" "$FSCK" "$XFS_CHECK" "$XFS_REPAIR" "$LVM" ; do test -n "$i" || error "Required command definitions in the script are missing!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fsadm-add-support-for-btrfs.patch
Type: text/x-patch
Size: 4860 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20170823/a455d07e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-test-add-fsadm-btrfs.sh.patch
Type: text/x-patch
Size: 3087 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20170823/a455d07e/attachment-0001.bin>
PATCH 1/1 added resizing for btrfs
Hi Eric,
ha! Nearly escaped my memory.
Re: your (justified) objections:
Quoted 3 lines
1. lack "check" action in your script
In patch [1], it uses "btrfs scrub", which I think you can replace it with "btrfs check".
1. You're right; btrfs scrub just checks the file/metadata checksums on a live system (and can thus correct /file breakage/), whereas btrfs check checks for structural damage.
I'm not sure btrfs scrub is the right thing to do ? certainly, it will detect corrupted blocks; but as far as I can see, these aren't a problem at all during resizing; they would be moved untouched.
I'm, on the other hand, also not sure we should implement anything here ? other filesystem checks are simply skipped if the filesystem is already mounted (and mounting is a requirement for resizing). btrfs check would take a long time.
So, either btrfs check or a nop; either is fine with me, what would you prefer?
Then: your code remarks
Quoted 10 lines
scripts/fsadm.sh +8
-0+resize_btrfs() { + detect_mounted + MOUNTPOINT=$MOUNTED + if [ -z "$MOUNTED" ]; then + MOUNTPOINT=$TEMPDIR + temp_mount || error "Cannot mount Btrfs filesystem." + fi + verbose "mounted on $MOUNTPOINT"Indention looks wrong?
Indeed :) will have to fix that.
Quoted 4 lines
scripts/fsadm.sh +3
-0+ + line_before="$last_line" + last_line="$i"There variables "
line_before" and "last_line" look redundant?
err, yes. I had a more complex parser in place for that needed two lines of history, but I was able to simplify it. My bad!
Now, I'll have to fix that too.
Thanks for the review!
Marcus
[3] https://btrfs.wiki.kernel.org/index.php/Btrfsck
Quoted 151 lines · Eric Ren
Hi Marcus,
I draft a test script [2] for this patch. I've tested our SUSE-specific patch[1] with this test script. But, I haven't test your patch yet.
I find two things in your patch, hope you can take another look:
1. lack "check" action in your script
In patch [1], it uses "btrfs scrub", which I think you can replace it with "btrfs check".2. some review comments inline below.
[1] 0001-fsadm-add-support-for-btrfs.patch
[2] 0002-test-add-fsadm-btrfs.sh.patchQuoted 36 lines · c M?ller
From: Marcus M?ller <[email protected]>
--- scripts/fsadm.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)scripts/fsadm.sh +7
-0@@ -22,6 +22,7 @@ # ext2/ext3/ext4: resize2fs, tune2fs # reiserfs: resize_reiserfs, reiserfstune # xfs: xfs_growfs, xfs_info +# btrfs: btrfs # # Return values: # 0 success@@ -41,6 +42,7 @@ TUNE_REISER=reiserfstune RESIZE_REISER=resize_reiserfs TUNE_XFS=xfs_info RESIZE_XFS=xfs_growfs +TOOL_BTRFS=btrfs MOUNT=mount UMOUNT=umount@@ -520,6 +522,70 @@ resize_xfs() { fi } +############################################################################### +# Resize BTRFS filesystem +# - mounted for upsize +# - mounted for downsize +# - since BTRFS supports multi-volume filesystems, only resize thebtrfs volume
scripts/fsadm.sh +1
-0+# we've actually resizedscripts/fsadm.sh resize_xfs() { · line 539
Quoted 10 lines
scripts/fsadm.sh +9
-0+############################################################################### +resize_btrfs() { + detect_mounted + MOUNTPOINT=$MOUNTED + if [ -z "$MOUNTED" ]; then + MOUNTPOINT=$TEMPDIR + temp_mount || error "Cannot mount Btrfs filesystem." + fi + verbose "mounted on $MOUNTPOINT"Indention looks wrong?
Verbose like "$subvolume mounted on $mnt"?
Quoted 26 lines
scripts/fsadm.sh +11
-0+ + local old_ifs="$IFS" + local last_line="" + local used="" + local devid="" + local devid_use="" + BLOCKSIZE=1 + + unset IFS + verbose "Parsing $TOOL_BTRFS filesystem show --raw \"$VOLUME\"" + for i in $(LC_ALL=C "$TOOL_BTRFS" filesystem show --raw"$VOLUME"); do
scripts/fsadm.sh +13
-0+ case "$last_line" in + "size") + BLOCKCOUNT=$i + ;; + "used") + used=$i + ;; + "devid") + devid="$i" + ;; + "path") + if test "$i" = "$VOLUME" ; then + verbose "Found $VOLUME; has devid $devid size$BLOCKCOUNT B"
scripts/fsadm.sh resize_xfs() { · line 570
Quoted 7 lines
scripts/fsadm.sh +7
-0+ devid_use="$devid" + fi + ;; + esac + + line_before="$last_line" + last_line="$i"There variables "
line_before" and "last_line" look redundant?Thanks,
EricQuoted 43 lines
scripts/fsadm.sh +11
-0+ done + IFS=old_ifs + + + validate_parsing "$TOOL_BTRFS" + decode_size "$BLOCKCOUNT" "$BLOCKSIZE" + FSFORCE=$FORCE + if test $(("$used")) -lt $(("$NEWSIZE")) ; then + verbose "$VOLUME: size $NEWSIZE B >= used $used B" + else + verbose "$VOLUME: trying to shrink filesystem to size$NEWSIZE B, which is less than used $used B"
scripts/fsadm.sh +3
-0+ verbose "$VOLUME: that might still work on multi-volume Btrfs" + fi + verbose "Resizing filesystem on device \"$VOLUME\", mounted on\"$MOUNTPOINT\" to $NEWSIZE bytes"
+ dry "$TOOL_BTRFS" filesystem resize "${devid_use}:${NEWSIZE}"
"$MOUNTPOINT"scripts/fsadm.sh +4
-0+ +} + #################### # Resize filesystem ####################@@ -536,6 +602,7 @@ resize() { "ext3"|"ext2"|"ext4") resize_ext $NEWSIZE ;; "reiserfs") resize_reiser $NEWSIZE ;; "xfs") resize_xfs $NEWSIZE ;; + "btrfs") resize_btrfs $NEWSIZE ;; *) error "Filesystem \"$FSTYPE\" on device \"$VOLUME\" is not supported by this tool." ;; esac || error "Resize $FSTYPE failed."cleanup 0
scripts/fsadm.sh +1
-1@@ -612,7 +679,7 @@ test -n "$FSADM_RUNNING" && exit 0 # test some prerequisities for i in "$TUNE_EXT" "$RESIZE_EXT" "$TUNE_REISER" "$RESIZE_REISER" \ - "$TUNE_XFS" "$RESIZE_XFS" "$MOUNT" "$UMOUNT" "$MKDIR" \ + "$TUNE_XFS" "$RESIZE_XFS" "$TOOL_BTRFS" "$MOUNT" "$UMOUNT" "$MKDIR" \ "$RMDIR" "$BLOCKDEV" "$BLKID" "$GREP" "$READLINK" \ "$DATE" "$FSCK" "$XFS_CHECK" "$XFS_REPAIR" "$LVM" ; do test -n "$i" || error "Required command definitions in thescript are missing!"
答复: Re: [PATCH 1/1] added resizing for btrfs
Hi,
Sorry for the delay.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Marcus M?ller <[email protected]> 2017-8-24 pm 15:25 >>>
Hi Eric,
Quoted 20 lines
Quoted 3 lines
ha! Nearly escaped my memory.
Re: your (justified) objections:
1. lack "check" action in your script
In patch [1], it uses "btrfs scrub", which I think you can replace it with "btrfs check".Quoted 12 lines
1. You're right;
btrfs scrubjust checks the file/metadata checksums on a live system (and can thus correct /file breakage/), whereasbtrfs checkchecks for structural damage.I'm not sure
btrfs scrubis the right thing to do ? certainly, it will detect corrupted blocks; but as far as I can see, these aren't a problem at all during resizing; they would be moved untouched.I'm, on the other hand, also not sure we should implement anything here ? other filesystem checks are simply skipped if the filesystem is already mounted (and mounting is a requirement for resizing).
btrfs checkwould take a long time.
Yeah, I overlooked this potential problem. IMHO, fsadm should have a option to decide if "check" is required after resize.
Quoted 2 lines
Quoted 2 lines
So, either btrfs check or a nop; either is fine with me, what would you prefer?
Hmm, the SUSE-specific patch was reviewed by btrfs-tools maintainer David Sterba, and tested by btrfs guys. I'd suggest to keep the way to check with "btrfs scrub" as in that patch.
Please send v2 after your changes, and I'll get the v2 patch, test it and then send the respective test script for Zdenek review.
Thanks!
Eric
答复: Re: [PATCH 1/1] added resizing for btrfs
Quoted 27 lines · Zhen Ren
Hi,
Sorry for the delay.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Marcus M?ller <[email protected]> 2017-8-24 pm 15:25 >>>
Hi Eric,
Quoted 15 lines
Quoted 2 lines
ha! Nearly escaped my memory.
Re: your (justified) objections:1. lack "check" action in your script
In patch [1], it uses "btrfs scrub", which I think you can replace it with "btrfs check".Quoted 10 lines
1. You're right;
btrfs scrubjust checks the file/metadata checksums on a live system (and can thus correct /file breakage/), whereasbtrfs checkchecks for structural damage.
I'm not surebtrfs scrubis the right thing to do ? certainly, it will detect corrupted blocks; but as far as I can see, these aren't a problem at all during resizing; they would be moved untouched.
I'm, on the other hand, also not sure we should implement anything here ? other filesystem checks are simply skipped if the filesystem is already mounted (and mounting is a requirement for resizing).btrfs checkwould take a long time.Yeah, I overlooked this potential problem. IMHO, fsadm should have a option to decide if "check" is required after resize.
Quoted 2 lines
Quoted 2 lines
So, either btrfs check or a nop; either is fine with me, what would you prefer?
Quoted 10 lines
Hmm, the SUSE-specific patch was reviewed by btrfs-tools maintainer David Sterba, and tested by btrfs guys. I'd suggest to keep the way to check with "btrfs scrub" as in that patch.
Please send v2 after your changes, and I'll get the v2 patch, test it and then send the respective test script for Zdenek review.
Thanks!
Eric
Hi Zhen,
I'm certainly not one to withhold a revised patch, but: If Lidong Zhong (hi!) got his patch reviewed already from btrfs folks ? I might personally prefer that
For example, the mount point detection based on the external findmnt program (didn't know that existed) looks more robust, and precautions that I didn't take (like setting LC_ALL for calling btrfs) indicate that the best-case modification of my patch would actually be his patch. I haven't thought of it this way so far.
Do you still want me to modify my patch?
Best regards,
Marcus
答复: Re: 答复: Re: [PATCH 1/1] added resizing for btrfs
Hi Marcus,
I am sending the patch as the attachment, please take for your reference. I wrote the patch almost two years ago and it passed my test cases that all I knew(I am not a btrfs specialist, so the patch probably solid enough). Eric knows the history. He could do more tests with your cooperation.
Regards,
Lidong
Quoted 1 line
Quoted 1 line
Quoted 1 line
Marcus M?ller <[email protected]> 2017-8-25 ?? 16:01 >>>
Quoted 27 lines · Zhen Ren
Hi,
Sorry for the delay.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Marcus M?ller <[email protected]> 2017-8-24 pm 15:25 >>>
Hi Eric,
Quoted 15 lines
Quoted 2 lines
ha! Nearly escaped my memory.
Re: your (justified) objections:1. lack "check" action in your script
In patch [1], it uses "btrfs scrub", which I think you can replace it with "btrfs check".Quoted 10 lines
1. You're right;
btrfs scrubjust checks the file/metadata checksums on a live system (and can thus correct /file breakage/), whereasbtrfs checkchecks for structural damage.
I'm not surebtrfs scrubis the right thing to do ? certainly, it will detect corrupted blocks; but as far as I can see, these aren't a problem at all during resizing; they would be moved untouched.
I'm, on the other hand, also not sure we should implement anything here ? other filesystem checks are simply skipped if the filesystem is already mounted (and mounting is a requirement for resizing).btrfs checkwould take a long time.Yeah, I overlooked this potential problem. IMHO, fsadm should have a option to decide if "check" is required after resize.
Quoted 2 lines
Quoted 2 lines
So, either btrfs check or a nop; either is fine with me, what would you prefer?
Quoted 10 lines
Hmm, the SUSE-specific patch was reviewed by btrfs-tools maintainer David Sterba, and tested by btrfs guys. I'd suggest to keep the way to check with "btrfs scrub" as in that patch.
Please send v2 after your changes, and I'll get the v2 patch, test it and then send the respective test script for Zdenek review.
Thanks!
Eric
Hi Zhen,
I'm certainly not one to withhold a revised patch, but: If Lidong Zhong (hi!) got his patch reviewed already from btrfs folks ? I might personally prefer that
For example, the mount point detection based on the external findmnt program (didn't know that existed) looks more robust, and precautions that I didn't take (like setting LC_ALL for calling btrfs) indicate that the best-case modification of my patch would actually be his patch. I haven't thought of it this way so far.
Do you still want me to modify my patch?
Best regards,
Marcus
--
lvm-devel mailing list
lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20170825/36465207/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsadm-add-support-for-btrfs.patch
Type: application/octet-stream
Size: 6321 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20170825/36465207/attachment.obj>
答复: Re: [PATCH 1/1] added resizing for btrfs
In reply to Marcus MüllerHi Marcus,
Quoted 6 lines · Marcus M?ller
[...snip...]
I'm certainly not one to withhold a revised patch, but: If Lidong Zhong (hi!) got his patch reviewed already from btrfs folks ? I might personally prefer that
Quoted 7 lines
For example, the mount point detection based on the external
findmntprogram (didn't know that existed) looks more robust, and precautions that I didn't take (like settingLC_ALLfor callingbtrfs) indicate that the best-case modification of my patch would actually be his patch. I haven't thought of it this way so far.Do you still want me to modify my patch?
I noticed that Lidong has posted his patch for you reference. So, feel free to take good points from his patch
into your v2 patch. Perhaps, you may give him credits by add "signed-off-by" in the patch header along with yours.
Thanks,
Eric
cover adding Btrfs resizing capability to lvresize/fsadm.sh
In reply to Marcus MüllerHello Marcus,
Do you get time to work out a version 2 of your patch based on my feedback and Lidong's patch?
Feel free to ask anything we can provide for help. I guess we're very close to make this thing into
upstream.
Regards,
Eric
Quoted 10 lines · Marcus M?ller
Hi Zdenek,
Thank you for the extensive explanation! I do agree, in this context, unverified functionality might be worse than none :)
Hi Eric,
Please do! And: please don't hesitate to ask for feedback of even better assistance if necessary - you're solving my problems, I'd like to help you with that.