/*
* Reset uid, gid or size for the PCC copy masked by @valid.
*/
-static int pcc_inode_reset_iattr(struct dentry *dentry, unsigned int valid,
+static int pcc_inode_reset_iattr(struct inode *lustre_inode,
+ struct dentry *dentry, unsigned int valid,
kuid_t uid, kgid_t gid, loff_t size)
{
struct inode *inode = dentry->d_inode;
attr.ia_uid = uid;
attr.ia_gid = gid;
attr.ia_size = size;
+ attr.ia_mtime = inode_get_mtime(lustre_inode);
inode_lock(inode);
rc = notify_change(&nop_mnt_idmap, dentry, &attr, NULL);
if (pcci == NULL)
GOTO(out_put, rc = -ENOMEM);
- rc = pcc_inode_reset_iattr(pcc_dentry, ATTR_UID | ATTR_GID,
+ rc = pcc_inode_reset_iattr(inode, pcc_dentry, ATTR_UID | ATTR_GID,
old_cred->suid, old_cred->sgid, 0);
if (rc)
GOTO(out_put, rc);
GOTO(out_dentry, rc);
}
- rc = pcc_inode_reset_iattr(*dentry, ATTR_UID | ATTR_GID,
+ rc = pcc_inode_reset_iattr(inode, *dentry, ATTR_UID | ATTR_GID,
old_cred->uid, old_cred->gid, 0);
if (rc)
GOTO(out_fput, rc);
* copy after copy data. Otherwise, it may get wrong file size after
* re-attach a file. See LU-13023 for details.
*/
- rc = pcc_inode_reset_iattr(*dentry, ATTR_SIZE, KUIDT_INIT(0),
- KGIDT_INIT(0), ret);
+ rc = pcc_inode_reset_iattr(inode, *dentry,
+ ATTR_SIZE | ATTR_MTIME | ATTR_MTIME_SET,
+ KUIDT_INIT(0), KGIDT_INIT(0), ret);
out_fput:
fput(pcc_filp);
out_dentry:
}
run_test 46 "Verify PCC mode setting works correctly"
+test_47() {
+ local loopfile="$TMP/$tfile"
+ local mntpt="/mnt/pcc.$tdir"
+ local hsm_root="$mntpt/$tdir"
+ local file=$DIR/$tfile
+
+ $LCTL get_param -n mdc.*.connect_flags | grep -q pcc_ro ||
+ skip "Server does not support PCC-RO"
+
+ setup_loopdev client $loopfile $mntpt 60
+ mkdir $hsm_root || error "mkdir $hsm_root failed"
+ setup_pcc_mapping client \
+ "projid={0}\ roid=$HSM_ARCHIVE_NUMBER\ ropcc=1\ mmap_conv=0"
+ $LCTL pcc list $MOUNT
+
+ local mtime0
+ local mtime1
+
+ echo "QQQQQ" > $file || error "echo $file failed"
+ mtime0=$(stat -c "%Y" $file);
+
+ sleep 3
+ cat $file || error "cat $file failed"
+ check_lpcc_state $file "readonly" client
+ mtime1=$(stat -c "%Y" $file)
+
+ (( mtime0 == mtime1 )) || error "mtime changed from $mtime0 to $mtime1"
+}
+run_test 47 "mtime should be kept once file attached into PCC"
+
test_96() {
local loopfile="$TMP/$tfile"
local mntpt="/mnt/pcc.$tdir"