From c7599286022252e36cefc70d358db740d6a27157 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Tue, 25 Mar 2025 15:12:32 -0400 Subject: [PATCH] Restore project ID, retention et al in restore_copy We didn't migrate the extra data from inodes on folders before, which is a gap in testing. Make sure to test with a nested restored folder to test that inheritance isn't in the way. Signed-off-by: Auke Kok --- tests/golden/restore_copy | 5 +++++ tests/src/restore_copy.c | 7 ++++--- tests/tests/restore_copy.sh | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/golden/restore_copy b/tests/golden/restore_copy index 718216c3..e223c8f1 100644 --- a/tests/golden/restore_copy +++ b/tests/golden/restore_copy @@ -16,6 +16,8 @@ f /mnt/test/data/mode_t f /mnt/test/data/uidgid f /mnt/test/data/retention f /mnt/test/data/proj +f /mnt/test/data/proj_d/f +d /mnt/test/data/proj_d d /mnt/test/data Quota rule: 7 13,L,- 0,L,- 0,L,- I 33 - Quota rule: 7 11,L,- 0,L,- 0,L,- I 33 - @@ -31,6 +33,7 @@ crw-r--r--. 1 0 0 2, 2 u -rw-r--r--. 1 0 0 16777216 truncate srwxr-xr-x. 1 0 0 0 s -rw-r--r--. 1 0 0 0 retention +drwxr-xr-x. 2 0 0 1 proj_d -rw-r--r--. 1 0 0 0 proj prw-r--r--. 1 0 0 0 p -rwsrwsrwx. 1 0 0 0 mode_t @@ -57,6 +60,8 @@ extents: 1 7 12,L,- 0,L,- 0,L,- I 33 - 7 11,L,- 0,L,- 0,L,- I 33 - 7 10,L,- 0,L,- 0,L,- I 33 - +12345 +54321 == verify quota rules on restored fs 7 14,L,- 0,L,- 0,L,- I 33 - 7 13,L,- 0,L,- 0,L,- I 33 - diff --git a/tests/src/restore_copy.c b/tests/src/restore_copy.c index f894bcfd..5dd2a76d 100644 --- a/tests/src/restore_copy.c +++ b/tests/src/restore_copy.c @@ -358,10 +358,11 @@ static struct scoutfs_parallel_restore_inode *read_inode_data(char *path, u64 in inode->data_seq = 0; inode->crtime = st.st_ctim; - if (S_ISREG(inode->mode)) { - if (inode->size > 0) - inode->offline = true; + /* we don't restore data */ + if (S_ISREG(inode->mode) && (inode->size > 0)) + inode->offline = true; + if (S_ISREG(inode->mode) || S_ISDIR(inode->mode)) { if (is_scoutfs) { fd = open(path, O_RDONLY); error_exit(!fd, "open failure"ERRF, ERRA); diff --git a/tests/tests/restore_copy.sh b/tests/tests/restore_copy.sh index 694c9532..7805d3ca 100644 --- a/tests/tests/restore_copy.sh +++ b/tests/tests/restore_copy.sh @@ -57,6 +57,10 @@ scoutfs set-attr-x -t 1 "$T_M0/data/retention" # set project ID touch "$T_M0/data/proj" scoutfs set-attr-x -p 12345 "$T_M0/data/proj" +mkdir -p "$T_M0/data/proj_d" +touch "$T_M0/data/proj_d/f" +scoutfs set-attr-x -p 12345 "$T_M0/data/proj_d/f" +scoutfs set-attr-x -p 54321 "$T_M0/data/proj_d" # quotas for a in $(seq 10 15); do scoutfs quota-add -p "$T_M0" -r "7 $a,L,- 0,L,- 0,L,- I 33 -" @@ -77,6 +81,8 @@ inspect() { scoutfs get-fiemap -L "falloc" scoutfs get-fiemap -L "truncate" scoutfs quota-list -p "." + scoutfs get-attr-x -p "proj_d/f" + scoutfs get-attr-x -p "proj_d" } ( cd "$SCR" ; inspect )