Skip to content

Commit f6fce9f

Browse files
Ashwin Gundarapujankara
authored andcommitted
ext2: Remove deprecated DAX support
DAX support in ext2 was deprecated in commit d5a2693 ("ext2: Deprecate DAX") with a removal deadline of end of 2025. Remove all DAX code from ext2 as scheduled. This removes the DAX mount option, IOMAP DAX support, DAX file operations, DAX address_space_operations, and the DAX fault handler. [JK: Fixup some whitespace damage] Signed-off-by: Ashwin Gundarapu <linuxuser509@zohomail.in> Link: https://patch.msgid.link/19e5aa07c9b.3a2e576d130187.5289857983023045470@zohomail.in Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 9ddaf06 commit f6fce9f

4 files changed

Lines changed: 8 additions & 211 deletions

File tree

fs/ext2/ext2.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ struct ext2_sb_info {
114114
*/
115115
spinlock_t s_lock;
116116
struct mb_cache *s_ea_block_cache;
117-
struct dax_device *s_daxdev;
118-
u64 s_dax_part_off;
119117
};
120118

121119
static inline spinlock_t *
@@ -373,11 +371,9 @@ struct ext2_inode {
373371
#define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */
374372
#define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */
375373
#define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */
376-
#define EXT2_MOUNT_XIP 0x010000 /* Obsolete, use DAX */
377374
#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
378375
#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
379376
#define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
380-
#define EXT2_MOUNT_DAX 0x100000 /* Direct Access */
381377

382378

383379
#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt

fs/ext2/file.c

Lines changed: 1 addition & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include <linux/time.h>
2323
#include <linux/pagemap.h>
24-
#include <linux/dax.h>
2524
#include <linux/filelock.h>
2625
#include <linux/quotaops.h>
2726
#include <linux/iomap.h>
@@ -32,111 +31,6 @@
3231
#include "acl.h"
3332
#include "trace.h"
3433

35-
#ifdef CONFIG_FS_DAX
36-
static ssize_t ext2_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
37-
{
38-
struct inode *inode = iocb->ki_filp->f_mapping->host;
39-
ssize_t ret;
40-
41-
if (!iov_iter_count(to))
42-
return 0; /* skip atime */
43-
44-
inode_lock_shared(inode);
45-
ret = dax_iomap_rw(iocb, to, &ext2_iomap_ops);
46-
inode_unlock_shared(inode);
47-
48-
file_accessed(iocb->ki_filp);
49-
return ret;
50-
}
51-
52-
static ssize_t ext2_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
53-
{
54-
struct file *file = iocb->ki_filp;
55-
struct inode *inode = file->f_mapping->host;
56-
ssize_t ret;
57-
58-
inode_lock(inode);
59-
ret = generic_write_checks(iocb, from);
60-
if (ret <= 0)
61-
goto out_unlock;
62-
ret = file_remove_privs(file);
63-
if (ret)
64-
goto out_unlock;
65-
ret = file_update_time(file);
66-
if (ret)
67-
goto out_unlock;
68-
69-
ret = dax_iomap_rw(iocb, from, &ext2_iomap_ops);
70-
if (ret > 0 && iocb->ki_pos > i_size_read(inode)) {
71-
i_size_write(inode, iocb->ki_pos);
72-
mark_inode_dirty(inode);
73-
}
74-
75-
out_unlock:
76-
inode_unlock(inode);
77-
if (ret > 0)
78-
ret = generic_write_sync(iocb, ret);
79-
return ret;
80-
}
81-
82-
/*
83-
* The lock ordering for ext2 DAX fault paths is:
84-
*
85-
* mmap_lock (MM)
86-
* sb_start_pagefault (vfs, freeze)
87-
* address_space->invalidate_lock
88-
* address_space->i_mmap_rwsem or page_lock (mutually exclusive in DAX)
89-
* ext2_inode_info->truncate_mutex
90-
*
91-
* The default page_lock and i_size verification done by non-DAX fault paths
92-
* is sufficient because ext2 doesn't support hole punching.
93-
*/
94-
static vm_fault_t ext2_dax_fault(struct vm_fault *vmf)
95-
{
96-
struct inode *inode = file_inode(vmf->vma->vm_file);
97-
vm_fault_t ret;
98-
bool write = (vmf->flags & FAULT_FLAG_WRITE) &&
99-
(vmf->vma->vm_flags & VM_SHARED);
100-
101-
if (write) {
102-
sb_start_pagefault(inode->i_sb);
103-
file_update_time(vmf->vma->vm_file);
104-
}
105-
filemap_invalidate_lock_shared(inode->i_mapping);
106-
107-
ret = dax_iomap_fault(vmf, 0, NULL, NULL, &ext2_iomap_ops);
108-
109-
filemap_invalidate_unlock_shared(inode->i_mapping);
110-
if (write)
111-
sb_end_pagefault(inode->i_sb);
112-
return ret;
113-
}
114-
115-
static const struct vm_operations_struct ext2_dax_vm_ops = {
116-
.fault = ext2_dax_fault,
117-
/*
118-
* .huge_fault is not supported for DAX because allocation in ext2
119-
* cannot be reliably aligned to huge page sizes and so pmd faults
120-
* will always fail and fail back to regular faults.
121-
*/
122-
.page_mkwrite = ext2_dax_fault,
123-
.pfn_mkwrite = ext2_dax_fault,
124-
};
125-
126-
static int ext2_file_mmap_prepare(struct vm_area_desc *desc)
127-
{
128-
struct file *file = desc->file;
129-
130-
if (!IS_DAX(file_inode(file)))
131-
return generic_file_mmap_prepare(desc);
132-
133-
file_accessed(file);
134-
desc->vm_ops = &ext2_dax_vm_ops;
135-
return 0;
136-
}
137-
#else
138-
#define ext2_file_mmap_prepare generic_file_mmap_prepare
139-
#endif
14034

14135
/*
14236
* Called when filp is released. This happens when all file descriptors
@@ -285,10 +179,6 @@ static ssize_t ext2_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
285179

286180
static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
287181
{
288-
#ifdef CONFIG_FS_DAX
289-
if (IS_DAX(iocb->ki_filp->f_mapping->host))
290-
return ext2_dax_read_iter(iocb, to);
291-
#endif
292182
if (iocb->ki_flags & IOCB_DIRECT)
293183
return ext2_dio_read_iter(iocb, to);
294184

@@ -297,10 +187,6 @@ static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
297187

298188
static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
299189
{
300-
#ifdef CONFIG_FS_DAX
301-
if (IS_DAX(iocb->ki_filp->f_mapping->host))
302-
return ext2_dax_write_iter(iocb, from);
303-
#endif
304190
if (iocb->ki_flags & IOCB_DIRECT)
305191
return ext2_dio_write_iter(iocb, from);
306192

@@ -321,7 +207,7 @@ const struct file_operations ext2_file_operations = {
321207
#ifdef CONFIG_COMPAT
322208
.compat_ioctl = ext2_compat_ioctl,
323209
#endif
324-
.mmap_prepare = ext2_file_mmap_prepare,
210+
.mmap_prepare = generic_file_mmap_prepare,
325211
.open = ext2_file_open,
326212
.release = ext2_release_file,
327213
.fsync = ext2_fsync,

fs/ext2/inode.c

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/time.h>
2727
#include <linux/highuid.h>
2828
#include <linux/pagemap.h>
29-
#include <linux/dax.h>
3029
#include <linux/blkdev.h>
3130
#include <linux/quotaops.h>
3231
#include <linux/writeback.h>
@@ -741,27 +740,6 @@ static int ext2_get_blocks(struct inode *inode,
741740
goto cleanup;
742741
}
743742

744-
if (IS_DAX(inode)) {
745-
/*
746-
* We must unmap blocks before zeroing so that writeback cannot
747-
* overwrite zeros with stale data from block device page cache.
748-
*/
749-
clean_bdev_aliases(inode->i_sb->s_bdev,
750-
le32_to_cpu(chain[depth-1].key),
751-
count);
752-
/*
753-
* block must be initialised before we put it in the tree
754-
* so that it's not found by another thread before it's
755-
* initialised
756-
*/
757-
err = sb_issue_zeroout(inode->i_sb,
758-
le32_to_cpu(chain[depth-1].key), count,
759-
GFP_KERNEL);
760-
if (err) {
761-
mutex_unlock(&ei->truncate_mutex);
762-
goto cleanup;
763-
}
764-
}
765743
*new = true;
766744

767745
ext2_splice_branch(inode, iblock, partial, indirect_blks, count);
@@ -811,7 +789,6 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
811789
unsigned int blkbits = inode->i_blkbits;
812790
unsigned long first_block = offset >> blkbits;
813791
unsigned long max_blocks = (length + (1 << blkbits) - 1) >> blkbits;
814-
struct ext2_sb_info *sbi = EXT2_SB(inode->i_sb);
815792
bool new = false, boundary = false;
816793
u32 bno;
817794
int ret;
@@ -841,10 +818,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
841818

842819
iomap->flags = 0;
843820
iomap->offset = (u64)first_block << blkbits;
844-
if (flags & IOMAP_DAX)
845-
iomap->dax_dev = sbi->s_daxdev;
846-
else
847-
iomap->bdev = inode->i_sb->s_bdev;
821+
iomap->bdev = inode->i_sb->s_bdev;
848822

849823
if (ret == 0) {
850824
/*
@@ -859,8 +833,6 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
859833
} else {
860834
iomap->type = IOMAP_MAPPED;
861835
iomap->addr = (u64)bno << blkbits;
862-
if (flags & IOMAP_DAX)
863-
iomap->addr += sbi->s_dax_part_off;
864836
iomap->length = (u64)ret << blkbits;
865837
iomap->flags |= IOMAP_F_MERGED;
866838
}
@@ -962,13 +934,6 @@ ext2_writepages(struct address_space *mapping, struct writeback_control *wbc)
962934
return mpage_writepages(mapping, wbc, ext2_get_block);
963935
}
964936

965-
static int
966-
ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc)
967-
{
968-
struct ext2_sb_info *sbi = EXT2_SB(mapping->host->i_sb);
969-
970-
return dax_writeback_mapping_range(mapping, sbi->s_daxdev, wbc);
971-
}
972937

973938
const struct address_space_operations ext2_aops = {
974939
.dirty_folio = block_dirty_folio,
@@ -984,10 +949,6 @@ const struct address_space_operations ext2_aops = {
984949
.error_remove_folio = generic_error_remove_folio,
985950
};
986951

987-
static const struct address_space_operations ext2_dax_aops = {
988-
.writepages = ext2_dax_writepages,
989-
.dirty_folio = noop_dirty_folio,
990-
};
991952

992953
/*
993954
* Probably it should be a library function... search for first non-zero word
@@ -1186,9 +1147,6 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset)
11861147
blocksize = inode->i_sb->s_blocksize;
11871148
iblock = (offset + blocksize-1) >> EXT2_BLOCK_SIZE_BITS(inode->i_sb);
11881149

1189-
#ifdef CONFIG_FS_DAX
1190-
WARN_ON(!rwsem_is_locked(&inode->i_mapping->invalidate_lock));
1191-
#endif
11921150

11931151
n = ext2_block_to_path(inode, iblock, offsets, NULL);
11941152
if (n == 0)
@@ -1290,12 +1248,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize)
12901248

12911249
inode_dio_wait(inode);
12921250

1293-
if (IS_DAX(inode))
1294-
error = dax_truncate_page(inode, newsize, NULL,
1295-
&ext2_iomap_ops);
1296-
else
1297-
error = block_truncate_page(inode->i_mapping,
1298-
newsize, ext2_get_block);
1251+
error = block_truncate_page(inode->i_mapping, newsize, ext2_get_block);
12991252
if (error)
13001253
return error;
13011254

@@ -1363,7 +1316,7 @@ void ext2_set_inode_flags(struct inode *inode)
13631316
unsigned int flags = EXT2_I(inode)->i_flags;
13641317

13651318
inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME |
1366-
S_DIRSYNC | S_DAX);
1319+
S_DIRSYNC);
13671320
if (flags & EXT2_SYNC_FL)
13681321
inode->i_flags |= S_SYNC;
13691322
if (flags & EXT2_APPEND_FL)
@@ -1374,18 +1327,13 @@ void ext2_set_inode_flags(struct inode *inode)
13741327
inode->i_flags |= S_NOATIME;
13751328
if (flags & EXT2_DIRSYNC_FL)
13761329
inode->i_flags |= S_DIRSYNC;
1377-
if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode))
1378-
inode->i_flags |= S_DAX;
13791330
}
13801331

13811332
void ext2_set_file_ops(struct inode *inode)
13821333
{
13831334
inode->i_op = &ext2_file_inode_operations;
13841335
inode->i_fop = &ext2_file_operations;
1385-
if (IS_DAX(inode))
1386-
inode->i_mapping->a_ops = &ext2_dax_aops;
1387-
else
1388-
inode->i_mapping->a_ops = &ext2_aops;
1336+
inode->i_mapping->a_ops = &ext2_aops;
13891337
}
13901338

13911339
struct inode *ext2_iget (struct super_block *sb, unsigned long ino)

0 commit comments

Comments
 (0)