From b48ed510791ae0f65d95ebbe6cca54a8cd605ca3 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sat, 14 Oct 2017 12:59:06 -0700 Subject: [PATCH] LU-9771 flr: make sure init size work Lustre allows to create a file with empty layout, and truncate it up with non-zero file size. The size should be applied later after a layout is attached. Test-Parameters: testlist=sanity-flr Signed-off-by: Jinshan Xiong Change-Id: Ie645f8172e98426a531eb2d9ffdcbec8f73f3731 Reviewed-on: https://review.whamcloud.com/29581 Reviewed-by: Jian Yu Reviewed-by: Bobi Jam Tested-by: Jenkins Tested-by: Maloo --- lustre/tests/sanity-flr.sh | 18 ++++++++++++++++-- lustre/utils/lfs.c | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 56eb391..146270c 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -226,8 +226,6 @@ test_0a() { verify_comp_attrs_with_parent $tf $id verify_comp_extent $tf $id 0 EOF - $mirror_cmd -N $tf &> /dev/null && - error "mirrored file $tf already exists" $mirror_cmd -N0 $tf-1 &> /dev/null && error "invalid mirror count 0" $mirror_cmd -N$((mirror_count + 1)) $tf-1 &> /dev/null && error "invalid mirror count $((mirror_count + 1))" @@ -649,6 +647,22 @@ test_4() { } run_test 4 "Make sure mirror attributes can be inhertied from directory" +test_5() { + local tf=$DIR/$tfile + local ids=() + + $MULTIOP $tf oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T12345c || + error "failed to create file with non-empty layout" + $CHECKSTAT -t file -s 12345 $tf || error "size error: expecting 12345" + + $LFS mirror create -N3 $tf || error "failed to attach mirror layout" + verify_mirror_count $tf 3 + + $CHECKSTAT -t file -s 12345 $tf || + error "size error after attaching layout " +} +run_test 5 "Make sure init size work for mirrored layout" + test_21() { local tf=$DIR/$tfile local tf2=$DIR/$tfile-2 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index c6f0f94..3cce36e 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -1134,7 +1134,7 @@ static int mirror_create(char *fname, struct mirror_args *mirror_list) goto error; } - rc = lfs_component_create(fname, O_CREAT | O_WRONLY | O_EXCL, 0644, + rc = lfs_component_create(fname, O_CREAT | O_WRONLY, 0644, layout); if (rc >= 0) { close(rc); -- 1.8.3.1