summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-21 16:37:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-21 16:37:39 -0400
commit70cb0d02b58128db07fc39b5e87a2873e2c16bde (patch)
tree43c0a4eb00f192ceb306b9c52503b2d54bc59660 /fs/ext4/ext4.h
parent104c0d6bc43e10ba84931c45b67e2c76c9c67f68 (diff)
parent040823b5372b445d1d9483811e85a24d71314d33 (diff)
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: "Added new ext4 debugging ioctls to allow userspace to get information about the state of the extent status cache. Dropped workaround for pre-1970 dates which were encoded incorrectly in pre-4.4 kernels. Since both the kernel correctly generates, and e2fsck detects and fixes this issue for the past four years, it'e time to drop the workaround. (Also, it's not like files with dates in the distant past were all that common in the first place.) A lot of miscellaneous bug fixes and cleanups, including some ext4 Documentation fixes. Also included are two minor bug fixes in fs/unicode" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (21 commits) unicode: make array 'token' static const, makes object smaller unicode: Move static keyword to the front of declarations ext4: add missing bigalloc documentation. ext4: fix kernel oops caused by spurious casefold flag ext4: fix integer overflow when calculating commit interval ext4: use percpu_counters for extent_status cache hits/misses ext4: fix potential use after free after remounting with noblock_validity jbd2: add missing tracepoint for reserved handle ext4: fix punch hole for inline_data file systems ext4: rework reserved cluster accounting when invalidating pages ext4: documentation fixes ext4: treat buffers with write errors as containing valid data ext4: fix warning inside ext4_convert_unwritten_extents_endio ext4: set error return correctly when ext4_htree_store_dirent fails ext4: drop legacy pre-1970 encoding workaround ext4: add new ioctl EXT4_IOC_GET_ES_CACHE ext4: add a new ioctl EXT4_IOC_GETSTATE ext4: add a new ioctl EXT4_IOC_CLEAR_ES_CACHE jbd2: flush_descriptor(): Do not decrease buffer head's ref count ext4: remove unnecessary error check ...
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r--fs/ext4/ext4.h64
1 files changed, 49 insertions, 15 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 42c6e4a5e673..03db3e71676c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -186,6 +186,14 @@ struct ext4_map_blocks {
186}; 186};
187 187
188/* 188/*
189 * Block validity checking, system zone rbtree.
190 */
191struct ext4_system_blocks {
192 struct rb_root root;
193 struct rcu_head rcu;
194};
195
196/*
189 * Flags for ext4_io_end->flags 197 * Flags for ext4_io_end->flags
190 */ 198 */
191#define EXT4_IO_END_UNWRITTEN 0x0001 199#define EXT4_IO_END_UNWRITTEN 0x0001
@@ -285,6 +293,9 @@ struct ext4_io_submit {
285 ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) 293 ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1))
286#define EXT4_LBLK_CMASK(s, lblk) ((lblk) & \ 294#define EXT4_LBLK_CMASK(s, lblk) ((lblk) & \
287 ~((ext4_lblk_t) (s)->s_cluster_ratio - 1)) 295 ~((ext4_lblk_t) (s)->s_cluster_ratio - 1))
296/* Fill in the low bits to get the last block of the cluster */
297#define EXT4_LBLK_CFILL(sbi, lblk) ((lblk) | \
298 ((ext4_lblk_t) (sbi)->s_cluster_ratio - 1))
288/* Get the cluster offset */ 299/* Get the cluster offset */
289#define EXT4_PBLK_COFF(s, pblk) ((pblk) & \ 300#define EXT4_PBLK_COFF(s, pblk) ((pblk) & \
290 ((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) 301 ((ext4_fsblk_t) (s)->s_cluster_ratio - 1))
@@ -653,6 +664,10 @@ enum {
653#define EXT4_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY 664#define EXT4_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
654#define EXT4_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT 665#define EXT4_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT
655#define EXT4_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY 666#define EXT4_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
667/* ioctl codes 19--39 are reserved for fscrypt */
668#define EXT4_IOC_CLEAR_ES_CACHE _IO('f', 40)
669#define EXT4_IOC_GETSTATE _IOW('f', 41, __u32)
670#define EXT4_IOC_GET_ES_CACHE _IOWR('f', 42, struct fiemap)
656 671
657#define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR 672#define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR
658#define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR 673#define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR
@@ -666,6 +681,16 @@ enum {
666#define EXT4_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */ 681#define EXT4_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */
667#define EXT4_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */ 682#define EXT4_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
668 683
684/*
685 * Flags returned by EXT4_IOC_GETSTATE
686 *
687 * We only expose to userspace a subset of the state flags in
688 * i_state_flags
689 */
690#define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001
691#define EXT4_STATE_FLAG_NEW 0x00000002
692#define EXT4_STATE_FLAG_NEWENTRY 0x00000004
693#define EXT4_STATE_FLAG_DA_ALLOC_CLOSE 0x00000008
669 694
670#if defined(__KERNEL__) && defined(CONFIG_COMPAT) 695#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
671/* 696/*
@@ -683,6 +708,12 @@ enum {
683#define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION 708#define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
684#endif 709#endif
685 710
711/*
712 * Returned by EXT4_IOC_GET_ES_CACHE as an additional possible flag.
713 * It indicates that the entry in extent status cache is for a hole.
714 */
715#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000
716
686/* Max physical block we can address w/o extents */ 717/* Max physical block we can address w/o extents */
687#define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF 718#define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF
688 719
@@ -812,21 +843,8 @@ static inline __le32 ext4_encode_extra_time(struct timespec64 *time)
812static inline void ext4_decode_extra_time(struct timespec64 *time, 843static inline void ext4_decode_extra_time(struct timespec64 *time,
813 __le32 extra) 844 __le32 extra)
814{ 845{
815 if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK))) { 846 if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK)))
816
817#if 1
818 /* Handle legacy encoding of pre-1970 dates with epoch
819 * bits 1,1. (This backwards compatibility may be removed
820 * at the discretion of the ext4 developers.)
821 */
822 u64 extra_bits = le32_to_cpu(extra) & EXT4_EPOCH_MASK;
823 if (extra_bits == 3 && ((time->tv_sec) & 0x80000000) != 0)
824 extra_bits = 0;
825 time->tv_sec += extra_bits << 32;
826#else
827 time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32; 847 time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32;
828#endif
829 }
830 time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; 848 time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS;
831} 849}
832 850
@@ -1427,7 +1445,7 @@ struct ext4_sb_info {
1427 int s_jquota_fmt; /* Format of quota to use */ 1445 int s_jquota_fmt; /* Format of quota to use */
1428#endif 1446#endif
1429 unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */ 1447 unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
1430 struct rb_root system_blks; 1448 struct ext4_system_blocks __rcu *system_blks;
1431 1449
1432#ifdef EXTENTS_STATS 1450#ifdef EXTENTS_STATS
1433 /* ext4 extents stats */ 1451 /* ext4 extents stats */
@@ -3267,6 +3285,9 @@ extern int ext4_ext_check_inode(struct inode *inode);
3267extern ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_ext_path *path); 3285extern ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_ext_path *path);
3268extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 3286extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3269 __u64 start, __u64 len); 3287 __u64 start, __u64 len);
3288extern int ext4_get_es_cache(struct inode *inode,
3289 struct fiemap_extent_info *fieinfo,
3290 __u64 start, __u64 len);
3270extern int ext4_ext_precache(struct inode *inode); 3291extern int ext4_ext_precache(struct inode *inode);
3271extern int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len); 3292extern int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len);
3272extern int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len); 3293extern int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len);
@@ -3359,6 +3380,19 @@ static inline void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end)
3359 3380
3360extern const struct iomap_ops ext4_iomap_ops; 3381extern const struct iomap_ops ext4_iomap_ops;
3361 3382
3383static inline int ext4_buffer_uptodate(struct buffer_head *bh)
3384{
3385 /*
3386 * If the buffer has the write error flag, we have failed
3387 * to write out data in the block. In this case, we don't
3388 * have to read the block because we may read the old data
3389 * successfully.
3390 */
3391 if (!buffer_uptodate(bh) && buffer_write_io_error(bh))
3392 set_buffer_uptodate(bh);
3393 return buffer_uptodate(bh);
3394}
3395
3362#endif /* __KERNEL__ */ 3396#endif /* __KERNEL__ */
3363 3397
3364#define EFSBADCRC EBADMSG /* Bad CRC detected */ 3398#define EFSBADCRC EBADMSG /* Bad CRC detected */