aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ext4_fs.h86
-rw-r--r--include/linux/ext4_fs_i.h5
-rw-r--r--include/linux/ext4_fs_sb.h1
3 files changed, 91 insertions, 1 deletions
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
index 45ec7258b2b1..df5e38faa15f 100644
--- a/include/linux/ext4_fs.h
+++ b/include/linux/ext4_fs.h
@@ -288,7 +288,7 @@ struct ext4_inode {
288 __le16 i_uid; /* Low 16 bits of Owner Uid */ 288 __le16 i_uid; /* Low 16 bits of Owner Uid */
289 __le32 i_size; /* Size in bytes */ 289 __le32 i_size; /* Size in bytes */
290 __le32 i_atime; /* Access time */ 290 __le32 i_atime; /* Access time */
291 __le32 i_ctime; /* Creation time */ 291 __le32 i_ctime; /* Inode Change time */
292 __le32 i_mtime; /* Modification time */ 292 __le32 i_mtime; /* Modification time */
293 __le32 i_dtime; /* Deletion Time */ 293 __le32 i_dtime; /* Deletion Time */
294 __le16 i_gid; /* Low 16 bits of Group Id */ 294 __le16 i_gid; /* Low 16 bits of Group Id */
@@ -337,10 +337,85 @@ struct ext4_inode {
337 } osd2; /* OS dependent 2 */ 337 } osd2; /* OS dependent 2 */
338 __le16 i_extra_isize; 338 __le16 i_extra_isize;
339 __le16 i_pad1; 339 __le16 i_pad1;
340 __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
341 __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */
342 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
343 __le32 i_crtime; /* File Creation time */
344 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
340}; 345};
341 346
342#define i_size_high i_dir_acl 347#define i_size_high i_dir_acl
343 348
349#define EXT4_EPOCH_BITS 2
350#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
351#define EXT4_NSEC_MASK (~0UL << EXT4_EPOCH_BITS)
352
353/*
354 * Extended fields will fit into an inode if the filesystem was formatted
355 * with large inodes (-I 256 or larger) and there are not currently any EAs
356 * consuming all of the available space. For new inodes we always reserve
357 * enough space for the kernel's known extended fields, but for inodes
358 * created with an old kernel this might not have been the case. None of
359 * the extended inode fields is critical for correct filesystem operation.
360 * This macro checks if a certain field fits in the inode. Note that
361 * inode-size = GOOD_OLD_INODE_SIZE + i_extra_isize
362 */
363#define EXT4_FITS_IN_INODE(ext4_inode, einode, field) \
364 ((offsetof(typeof(*ext4_inode), field) + \
365 sizeof((ext4_inode)->field)) \
366 <= (EXT4_GOOD_OLD_INODE_SIZE + \
367 (einode)->i_extra_isize)) \
368
369static inline __le32 ext4_encode_extra_time(struct timespec *time)
370{
371 return cpu_to_le32((sizeof(time->tv_sec) > 4 ?
372 time->tv_sec >> 32 : 0) |
373 ((time->tv_nsec << 2) & EXT4_NSEC_MASK));
374}
375
376static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
377{
378 if (sizeof(time->tv_sec) > 4)
379 time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK)
380 << 32;
381 time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2;
382}
383
384#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \
385do { \
386 (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \
387 if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
388 (raw_inode)->xtime ## _extra = \
389 ext4_encode_extra_time(&(inode)->xtime); \
390} while (0)
391
392#define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode) \
393do { \
394 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
395 (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec); \
396 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
397 (raw_inode)->xtime ## _extra = \
398 ext4_encode_extra_time(&(einode)->xtime); \
399} while (0)
400
401#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode) \
402do { \
403 (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \
404 if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
405 ext4_decode_extra_time(&(inode)->xtime, \
406 raw_inode->xtime ## _extra); \
407} while (0)
408
409#define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode) \
410do { \
411 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
412 (einode)->xtime.tv_sec = \
413 (signed)le32_to_cpu((raw_inode)->xtime); \
414 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
415 ext4_decode_extra_time(&(einode)->xtime, \
416 raw_inode->xtime ## _extra); \
417} while (0)
418
344#if defined(__KERNEL__) || defined(__linux__) 419#if defined(__KERNEL__) || defined(__linux__)
345#define i_reserved1 osd1.linux1.l_i_reserved1 420#define i_reserved1 osd1.linux1.l_i_reserved1
346#define i_frag osd2.linux2.l_i_frag 421#define i_frag osd2.linux2.l_i_frag
@@ -539,6 +614,13 @@ static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
539 return container_of(inode, struct ext4_inode_info, vfs_inode); 614 return container_of(inode, struct ext4_inode_info, vfs_inode);
540} 615}
541 616
617static inline struct timespec ext4_current_time(struct inode *inode)
618{
619 return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
620 current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
621}
622
623
542static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) 624static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
543{ 625{
544 return ino == EXT4_ROOT_INO || 626 return ino == EXT4_ROOT_INO ||
@@ -609,6 +691,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
609#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 691#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
610#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 692#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
611#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 693#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
694#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
612 695
613#define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001 696#define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
614#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002 697#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
@@ -626,6 +709,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
626 EXT4_FEATURE_INCOMPAT_64BIT) 709 EXT4_FEATURE_INCOMPAT_64BIT)
627#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ 710#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
628 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ 711 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
712 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
629 EXT4_FEATURE_RO_COMPAT_BTREE_DIR) 713 EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
630 714
631/* 715/*
diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
index 9de494406995..1a511e9905aa 100644
--- a/include/linux/ext4_fs_i.h
+++ b/include/linux/ext4_fs_i.h
@@ -153,6 +153,11 @@ struct ext4_inode_info {
153 153
154 unsigned long i_ext_generation; 154 unsigned long i_ext_generation;
155 struct ext4_ext_cache i_cached_extent; 155 struct ext4_ext_cache i_cached_extent;
156 /*
157 * File creation time. Its function is same as that of
158 * struct timespec i_{a,c,m}time in the generic inode.
159 */
160 struct timespec i_crtime;
156}; 161};
157 162
158#endif /* _LINUX_EXT4_FS_I */ 163#endif /* _LINUX_EXT4_FS_I */
diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
index 0f7dc15924bf..1b2ffee12be9 100644
--- a/include/linux/ext4_fs_sb.h
+++ b/include/linux/ext4_fs_sb.h
@@ -81,6 +81,7 @@ struct ext4_sb_info {
81 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */ 81 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
82 int s_jquota_fmt; /* Format of quota to use */ 82 int s_jquota_fmt; /* Format of quota to use */
83#endif 83#endif
84 unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
84 85
85#ifdef EXTENTS_STATS 86#ifdef EXTENTS_STATS
86 /* ext4 extents stats */ 87 /* ext4 extents stats */