Restore hardlink count.

The hardlink count of files was previously hard coded to 1. We want to
properly restore hard linked files because it saves space and time.

The test binary restore_copy exposed this missed case before and is updated
to make use of it.

Signed-off-by: Auke Kok <auke.kok@versity.com>
This commit is contained in:
Auke Kok
2025-01-16 11:34:26 -08:00
parent a2eb157a1f
commit e4f5fc4682
4 changed files with 5 additions and 3 deletions

View File

@@ -35,10 +35,10 @@ srwxr-xr-x. 1 0 0 0 s
prw-r--r--. 1 0 0 0 p
-rwsrwsrwx. 1 0 0 0 mode_t
lrwxrwxrwx. 1 0 0 7 l -> broken
-rw-r--r--. 1 0 0 0 h
-rw-r--r--. 2 0 0 0 h
-rw-r--r--. 1 0 0 131072 falloc
-rw-r--r--. 1 0 0 4096 f4096
-rw-r--r--. 1 0 0 0 f
-rw-r--r--. 2 0 0 0 f
drwxr-xr-x. 2 0 0 0 d
crw-r--r--. 1 0 0 0, 0 c
brw-r--r--. 1 0 0 1, 1 b

View File

@@ -349,6 +349,7 @@ static struct scoutfs_parallel_restore_inode *read_inode_data(char *path, u64 in
inode->ctime = st.st_ctim;
inode->mtime = st.st_mtim;
inode->size = st.st_size;
inode->nlink = st.st_nlink;
inode->rdev = st.st_rdev;

View File

@@ -813,7 +813,7 @@ static spr_err_t insert_inode_items(struct scoutfs_parallel_restore_writer *wri,
si->next_readdir_pos = 0;
si->next_xattr_id = cpu_to_le64(inode->nr_xattrs + 1);
si->version = cpu_to_le64(1);
si->nlink = cpu_to_le32(1);
si->nlink = cpu_to_le32(inode->nlink ? inode->nlink : 1);
si->uid = cpu_to_le32(inode->uid);
si->gid = cpu_to_le32(inode->gid);
si->mode = cpu_to_le32(inode->mode);

View File

@@ -58,6 +58,7 @@ struct scoutfs_parallel_restore_inode {
u64 data_version;
u64 size;
bool offline;
u32 nlink;
/* only used for directories */
u64 nr_subdirs;