115 lines
3.8 KiB
Diff
115 lines
3.8 KiB
Diff
From 0626a247f1b30b71f74f0eb7cd0890c4c469e6a6 Mon Sep 17 00:00:00 2001
|
|
From: liqiang <liqiang64@huawei.com>
|
|
Date: Wed, 13 Dec 2023 14:48:11 +0800
|
|
Subject: [PATCH 10/12] bugfix: unix socket connection refuse after chmod
|
|
modify socket file
|
|
|
|
Signed-off-by: liqiang <liqiang64@huawei.com>
|
|
---
|
|
qtfs/qtfs/sb.c | 38 ++++++++++++++++++++++++++++++++------
|
|
1 file changed, 32 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/qtfs/qtfs/sb.c b/qtfs/qtfs/sb.c
|
|
index fefb6c1..4ecbf50 100644
|
|
--- a/qtfs/qtfs/sb.c
|
|
+++ b/qtfs/qtfs/sb.c
|
|
@@ -35,6 +35,17 @@ static struct inode_operations qtfs_inode_ops;
|
|
static struct inode_operations qtfs_symlink_inode_ops;
|
|
struct inode *qtfs_iget(struct super_block *sb, struct inode_info *ii);
|
|
extern ssize_t qtfs_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size);
|
|
+static void qtfs_copy_kstat_inode(struct inode *inode, struct kstat *stat)
|
|
+{
|
|
+ inode->i_mode = stat->mode;
|
|
+ inode->i_size = stat->size;
|
|
+ inode->i_uid = stat->uid;
|
|
+ inode->i_gid = stat->gid;
|
|
+ inode->i_atime = stat->atime;
|
|
+ inode->i_mtime = stat->mtime;
|
|
+ inode->i_ctime = stat->ctime;
|
|
+}
|
|
+
|
|
int qtfs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
|
{
|
|
struct qtfs_conn_var_s *pvar = qtfs_conn_get_param();
|
|
@@ -1340,16 +1351,28 @@ int qtfs_getattr(const struct path *path, struct kstat *stat, u32 req_mask, unsi
|
|
path->dentry->d_time = jiffies;
|
|
qtfs_debug("qtfs getattr success:<%s> blksiz:%u size:%lld mode:%o ino:%llu pathino:%lu. %s\n", req->path, rsp->stat.blksize,
|
|
rsp->stat.size, rsp->stat.mode, rsp->stat.ino, inode->i_ino, rsp->stat.ino != inode->i_ino ? "delete current inode" : "");
|
|
- if (inode->i_ino != rsp->stat.ino || inode->i_mode != rsp->stat.mode) {
|
|
+ if (inode->i_ino != rsp->stat.ino) {
|
|
if (inode->i_nlink > 0){
|
|
drop_nlink(inode);
|
|
}
|
|
d_invalidate(path->dentry);
|
|
}
|
|
+ qtfs_copy_kstat_inode(inode, &rsp->stat);
|
|
qtfs_conn_put_param(pvar);
|
|
return 0;
|
|
}
|
|
|
|
+static void qtfs_copy_iattr_inode(struct inode *inode, struct iattr *attr)
|
|
+{
|
|
+ inode->i_mode = attr->ia_mode;
|
|
+ inode->i_uid = attr->ia_uid;
|
|
+ inode->i_gid = attr->ia_gid;
|
|
+ inode->i_size = attr->ia_size;
|
|
+ inode->i_atime = attr->ia_atime;
|
|
+ inode->i_mtime = attr->ia_mtime;
|
|
+ inode->i_ctime = attr->ia_ctime;
|
|
+}
|
|
+
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0))
|
|
int qtfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
|
|
@@ -1385,6 +1408,8 @@ int qtfs_setattr(struct dentry *dentry, struct iattr *attr)
|
|
qtfs_conn_put_param(pvar);
|
|
return ret;
|
|
}
|
|
+ // 成功后更新local的inode信息
|
|
+ qtfs_copy_iattr_inode(dentry->d_inode, &req->attr);
|
|
qtfs_info("qtfs setattr <%s> success.\n", req->path);
|
|
qtfs_conn_put_param(pvar);
|
|
return 0;
|
|
@@ -1558,7 +1583,7 @@ int qtfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
|
|
pvar = qtfs_conn_get_param();
|
|
if (!pvar) {
|
|
qtfs_err("Failed to get qtfs sock var\n");
|
|
- return 0;
|
|
+ return 1;
|
|
}
|
|
|
|
req = pvar->conn_ops->get_conn_msg_buf(pvar, QTFS_SEND);
|
|
@@ -1569,24 +1594,25 @@ int qtfs_dentry_revalidate(struct dentry *dentry, unsigned int flags)
|
|
rsp = qtfs_remote_run(pvar, QTFS_REQ_GETATTR, QTFS_SEND_SIZE(struct qtreq_getattr, req->path));
|
|
if (IS_ERR_OR_NULL(rsp)) {
|
|
qtfs_conn_put_param(pvar);
|
|
- return 0;
|
|
+ return 1;
|
|
}
|
|
if (rsp->ret) {
|
|
qtfs_conn_put_param(pvar);
|
|
- return 0;
|
|
+ return 1;
|
|
}
|
|
|
|
inode = dentry->d_inode;
|
|
if (inode == NULL) {
|
|
qtfs_conn_put_param(pvar);
|
|
- return 0;
|
|
+ return 1;
|
|
}
|
|
- if (inode->i_ino != rsp->stat.ino || inode->i_mode != rsp->stat.mode) {
|
|
+ if (inode->i_ino != rsp->stat.ino) {
|
|
if (inode->i_nlink > 0)
|
|
drop_nlink(inode);
|
|
qtfs_conn_put_param(pvar);
|
|
return 0;
|
|
}
|
|
+ qtfs_copy_kstat_inode(inode, &rsp->stat);
|
|
qtfs_conn_put_param(pvar);
|
|
dentry->d_time = jiffies;
|
|
}
|
|
--
|
|
2.37.1 (Apple Git-137.1)
|
|
|