[Devel] [PATCH 2/3] fs/fuse kio: sync pcs_mds_sys_info struct

Pavel Butsykin pbutsykin at virtuozzo.com
Tue Mar 26 18:07:10 MSK 2019


For some reason pcs_mds_sys_info structure is different in the kernel and
userspace. Let's synchronize it to avoid inaccuracies and discrepancies in
the future.

Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_client_types.h |  6 +++---
 fs/fuse/kio/pcs/pcs_cluster.c      |  8 ++++----
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c |  2 +-
 fs/fuse/kio/pcs/pcs_prot_types.h   | 10 ++++++----
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_client_types.h b/fs/fuse/kio/pcs/pcs_client_types.h
index 1be32cbbf285..c0d14ec5b5d4 100644
--- a/fs/fuse/kio/pcs/pcs_client_types.h
+++ b/fs/fuse/kio/pcs/pcs_client_types.h
@@ -87,9 +87,9 @@ static inline void pcs_set_fileinfo(struct pcs_dentry_info *i, const struct pcs_
 
 	if (mi->sys.stripe_depth == 0) {
 		mi->sys.stripe_depth = 1;
-		mi->sys.strip_width = mi->sys.chunk_size;
+		mi->sys.strip_width = mi->sys.chunk_size_lo;
 	}
-	i->mapping.chunk_size_bits = ilog2(mi->sys.chunk_size);
+	i->mapping.chunk_size_bits = ilog2(mi->sys.chunk_size_lo);
 
 }
 
@@ -170,7 +170,7 @@ typedef struct _pcs_api_csconnreq_t {
 #define DENTRY_ARGS(de)	      PCS_FILE_ID_ARGS((de)->id.parent), PCS_FILE_ID_ARGS((de)->fileinfo.attr.id)
 
 #define DENTRY_SIZE(de)       ((de)->fileinfo.attr.size)
-#define DENTRY_CHUNK_SIZE(de) ((de)->fileinfo.sys.chunk_size)
+#define DENTRY_CHUNK_SIZE(de) ((de)->fileinfo.sys.chunk_size_lo)
 #define DENTRY_CHUNK_SIZE_BITS(de) ((de)->mapping.chunk_size_bits)
 
 void pcs_mapset_limit(struct pcs_map_set *maps, int limit);
diff --git a/fs/fuse/kio/pcs/pcs_cluster.c b/fs/fuse/kio/pcs/pcs_cluster.c
index 5df263f01f98..a73120c97e5e 100644
--- a/fs/fuse/kio/pcs/pcs_cluster.c
+++ b/fs/fuse/kio/pcs/pcs_cluster.c
@@ -364,9 +364,9 @@ static noinline void __pcs_cc_process_ireq_rw(struct pcs_int_request *ireq)
 		unsigned int len;
 		u64 rpos, chunk, end_pos;
 
-		rpos = map_file_to_chunk(pos, di->fileinfo.sys.chunk_size, di->fileinfo.sys.stripe_depth, di->fileinfo.sys.strip_width);
+		rpos = map_file_to_chunk(pos, di->fileinfo.sys.chunk_size_lo, di->fileinfo.sys.stripe_depth, di->fileinfo.sys.strip_width);
 
-		chunk = rpos & ~((u64)di->fileinfo.sys.chunk_size - 1);
+		chunk = rpos & ~((u64)di->fileinfo.sys.chunk_size_lo - 1);
 		end_pos = ((rpos / di->fileinfo.sys.strip_width) + 1) * (u64)di->fileinfo.sys.strip_width;
 
 		sreq = ireq_alloc(di);
@@ -385,9 +385,9 @@ static noinline void __pcs_cc_process_ireq_rw(struct pcs_int_request *ireq)
 		sreq->iochunk.cmd = ireq->apireq.req->type;
 		sreq->iochunk.cs_index = 0;
 		sreq->iochunk.chunk = chunk;
-		sreq->iochunk.offset = rpos % di->fileinfo.sys.chunk_size;
+		sreq->iochunk.offset = rpos % di->fileinfo.sys.chunk_size_lo;
 		sreq->iochunk.dio_offset = dio_offset;
-		len = di->fileinfo.sys.chunk_size - sreq->iochunk.offset;
+		len = di->fileinfo.sys.chunk_size_lo - sreq->iochunk.offset;
 		if (len > sz)
 			len = sz;
 		if (rpos + len > end_pos)
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 875ad18df4a7..6d12b8038e8a 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -343,7 +343,7 @@ static int kpcs_do_file_open(struct fuse_conn *fc, struct file *file, struct ino
 	INIT_LIST_HEAD(&di->kq);
 	spin_lock_init(&di->kq_lock);
 	TRACE("init id:%llu chunk_size:%d stripe_depth:%d strip_width:%d\n",
-	      fi->nodeid, di->fileinfo.sys.chunk_size,
+	      fi->nodeid, di->fileinfo.sys.chunk_size_lo,
 	      di->fileinfo.sys.stripe_depth, di->fileinfo.sys.strip_width);
 
 	ret = fuse_pcs_kdirect_claim_op(fc, file, true);
diff --git a/fs/fuse/kio/pcs/pcs_prot_types.h b/fs/fuse/kio/pcs/pcs_prot_types.h
index bba1f1dc76e3..0e7bc9743885 100644
--- a/fs/fuse/kio/pcs/pcs_prot_types.h
+++ b/fs/fuse/kio/pcs/pcs_prot_types.h
@@ -104,15 +104,17 @@ struct __pre_aligned(8) pcs_mds_fattr
 };
 
 struct __pre_aligned(8) pcs_mds_sys_info {
-	u32	map_type;     /* reserved for RAID */
-	u32	chunk_size;   /* global constant */
+	u8	map_type;     /* reserved for RAID */
+	u8	reserved[2];
+	u8	chunk_size_hi; /* chunk size (hi bits) */
+	u32	chunk_size_lo; /* chunk size (lo bits) */
 	u8	stripe_depth; /* for RAID6/RS  */
 	u8	redundancy;   /* number of checksums for RAID6/RS */
 	u8	tolerance;    /* write-tolerance (how much lost replicas we can tolerate still allowing writing) */
-	u8	reserved8;
+	u8	reserved2;
 	u32	strip_width;  /* length of strip for RAID6/RS */
 	u32	lease_tout;   /* lease expiration timeout (in milliseconds) */
-	u32	reserved;
+	u32	reserved3;
 } __aligned(8);
 
 #define PCS_CHUNK_SIZE_MIN 4096u
-- 
2.15.1



More information about the Devel mailing list