summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2017-12-25 19:19:53 +0530
committerAmar Tumballi <amarts@redhat.com>2017-12-29 17:13:25 +0000
commit9fd17c1c3c44944ea280c4c15bad0d49b298b8a9 (patch)
tree26620d09b2e7fd55aff5a302d8bd15f547352e2b /libglusterfs
parentcc425b0de57d574f6e68b6ef5edfdf99cd8353af (diff)
posix: Introduce flags for validity of iatt members
v1 of the patch started off as adding new fields to iatt that can be filled up using statx but the discussions were more around introducing masks to check the validity of different fields from a RIO perspective. To that extent, I have dropped the statx call in this version and introduced a 64 bit mask for existing fields. The masks I have defined are similar with the statx() flags' masks. I have *not* changed iatt_to_stat() to use the macros IATT_TYPE_VALID, IATT_GFID_VALID etc before blindly copying from struct iatt to struct. Also fixed warnings in xlators because of atime/mtime/ctime seconds field change from uint32_t to int64_t. Change-Id: I4ac614f1e8d5c8246fc99d5bc2d2a23e7941512b Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/iatt.h59
1 files changed, 49 insertions, 10 deletions
diff --git a/libglusterfs/src/iatt.h b/libglusterfs/src/iatt.h
index b8907598b18..8cb2b4a5b27 100644
--- a/libglusterfs/src/iatt.h
+++ b/libglusterfs/src/iatt.h
@@ -33,7 +33,6 @@ typedef enum {
IA_IFSOCK
} ia_type_t;
-
typedef struct {
uint8_t suid:1;
uint8_t sgid:1;
@@ -45,28 +44,63 @@ typedef struct {
} owner, group, other;
} ia_prot_t;
-
struct iatt {
+ uint64_t ia_flags;
uint64_t ia_ino; /* inode number */
- uuid_t ia_gfid;
uint64_t ia_dev; /* backing device ID */
- ia_type_t ia_type; /* type of file */
- ia_prot_t ia_prot; /* protection */
+ uint64_t ia_rdev; /* device ID (if special file) */
+ uint64_t ia_size; /* file size in bytes */
uint32_t ia_nlink; /* Link count */
uint32_t ia_uid; /* user ID of owner */
uint32_t ia_gid; /* group ID of owner */
- uint64_t ia_rdev; /* device ID (if special file) */
- uint64_t ia_size; /* file size in bytes */
uint32_t ia_blksize; /* blocksize for filesystem I/O */
uint64_t ia_blocks; /* number of 512B blocks allocated */
- uint32_t ia_atime; /* last access time */
+ int64_t ia_atime; /* last access time */
+ int64_t ia_mtime; /* last modification time */
+ int64_t ia_ctime; /* last status change time */
+ int64_t ia_btime; /* creation time. Fill using statx */
uint32_t ia_atime_nsec;
- uint32_t ia_mtime; /* last modification time */
uint32_t ia_mtime_nsec;
- uint32_t ia_ctime; /* last status change time */
uint32_t ia_ctime_nsec;
+ uint32_t ia_btime_nsec;
+ uint64_t ia_attributes; /* chattr related:compressed, immutable,
+ * append only, encrypted etc.*/
+ uint64_t ia_attributes_mask; /* Mask for the attributes */
+
+ uuid_t ia_gfid;
+ ia_type_t ia_type; /* type of file */
+ ia_prot_t ia_prot; /* protection */
};
+/* 64-bit mask for valid members in struct iatt. */
+#define IATT_TYPE 0x0000000000000001U
+#define IATT_MODE 0x0000000000000002U
+#define IATT_NLINK 0x0000000000000004U
+#define IATT_UID 0x0000000000000008U
+#define IATT_GID 0x0000000000000010U
+#define IATT_ATIME 0x0000000000000020U
+#define IATT_MTIME 0x0000000000000040U
+#define IATT_CTIME 0x0000000000000080U
+#define IATT_INO 0x0000000000000100U
+#define IATT_SIZE 0x0000000000000200U
+#define IATT_BLOCKS 0x0000000000000400U
+#define IATT_BTIME 0x0000000000000800U
+#define IATT_GFID 0x0000000000001000U
+
+/* Macros for checking validity of struct iatt members.*/
+#define IATT_TYPE_VALID(iaflags) (iaflags & IATT_TYPE)
+#define IATT_MODE_VALID(iaflags) (iaflags & IATT_MODE)
+#define IATT_NLINK_VALID(iaflags) (iaflags & IATT_NLINK)
+#define IATT_UID_VALID(iaflags) (iaflags & IATT_UID)
+#define IATT_GID_VALID(iaflags) (iaflags & IATT_GID)
+#define IATT_ATIME_VALID(iaflags) (iaflags & IATT_ATIME)
+#define IATT_MTIME_VALID(iaflags) (iaflags & IATT_MTIME)
+#define IATT_CTIME_VALID(iaflags) (iaflags & IATT_CTIME)
+#define IATT_INO_VALID(iaflags) (iaflags & IATT_INO)
+#define IATT_SIZE_VALID(iaflags) (iaflags & IATT_SIZE)
+#define IATT_BLOCKS_VALID(iaflags) (iaflags & IATT_BLOCKS)
+#define IATT_BTIME_VALID(iaflags) (iaflags & IATT_BTIME)
+#define IATT_GFID_VALID(iaflags) (iaflags & IATT_GFID)
#define IA_ISREG(t) (t == IA_IFREG)
#define IA_ISDIR(t) (t == IA_IFDIR)
@@ -302,6 +336,11 @@ iatt_from_stat (struct iatt *iatt, struct stat *stat)
iatt->ia_ctime = stat->st_ctime;
iatt->ia_ctime_nsec = ST_CTIM_NSEC (stat);
+ /* Setting IATT_INO in ia_flags is done in posix_fill_ino_from_gfid. */
+ iatt->ia_flags = iatt->ia_flags | IATT_TYPE | IATT_MODE | IATT_NLINK |
+ IATT_UID | IATT_GID | IATT_SIZE | IATT_BLOCKS |
+ IATT_ATIME | IATT_MTIME | IATT_CTIME;
+
return 0;
}