Skip to content

Commit 9f4736f

Browse files
committed
block: revert runtime dax control of the raw block device
Dynamically enabling DAX requires that the page cache first be flushed and invalidated. This must occur atomically with the change of DAX mode otherwise we confuse the fsync/msync tracking and violate data durability guarantees. Eliminate the possibilty of DAX-disabled to DAX-enabled transitions for now and revisit this for the next cycle. Cc: Jan Kara <[email protected]> Cc: Jeff Moyer <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Dave Chinner <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Ross Zwisler <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 65f87ee commit 9f4736f

File tree

4 files changed

+0
-70
lines changed

4 files changed

+0
-70
lines changed

block/ioctl.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -434,42 +434,6 @@ bool blkdev_dax_capable(struct block_device *bdev)
434434

435435
return true;
436436
}
437-
438-
static int blkdev_daxset(struct block_device *bdev, unsigned long argp)
439-
{
440-
unsigned long arg;
441-
int rc = 0;
442-
443-
if (!capable(CAP_SYS_ADMIN))
444-
return -EACCES;
445-
446-
if (get_user(arg, (int __user *)(argp)))
447-
return -EFAULT;
448-
arg = !!arg;
449-
if (arg == !!(bdev->bd_inode->i_flags & S_DAX))
450-
return 0;
451-
452-
if (arg)
453-
arg = S_DAX;
454-
455-
if (arg && !blkdev_dax_capable(bdev))
456-
return -ENOTTY;
457-
458-
inode_lock(bdev->bd_inode);
459-
if (bdev->bd_map_count == 0)
460-
inode_set_flags(bdev->bd_inode, arg, S_DAX);
461-
else
462-
rc = -EBUSY;
463-
inode_unlock(bdev->bd_inode);
464-
return rc;
465-
}
466-
#else
467-
static int blkdev_daxset(struct block_device *bdev, int arg)
468-
{
469-
if (arg)
470-
return -ENOTTY;
471-
return 0;
472-
}
473437
#endif
474438

475439
static int blkdev_flushbuf(struct block_device *bdev, fmode_t mode,
@@ -634,8 +598,6 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
634598
case BLKTRACESETUP:
635599
case BLKTRACETEARDOWN:
636600
return blk_trace_ioctl(bdev, cmd, argp);
637-
case BLKDAXSET:
638-
return blkdev_daxset(bdev, arg);
639601
case BLKDAXGET:
640602
return put_int(arg, !!(bdev->bd_inode->i_flags & S_DAX));
641603
break;

fs/block_dev.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,56 +1736,28 @@ static int blkdev_dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr,
17361736
return __dax_pmd_fault(vma, addr, pmd, flags, blkdev_get_block, NULL);
17371737
}
17381738

1739-
static void blkdev_vm_open(struct vm_area_struct *vma)
1740-
{
1741-
struct inode *bd_inode = bdev_file_inode(vma->vm_file);
1742-
struct block_device *bdev = I_BDEV(bd_inode);
1743-
1744-
inode_lock(bd_inode);
1745-
bdev->bd_map_count++;
1746-
inode_unlock(bd_inode);
1747-
}
1748-
1749-
static void blkdev_vm_close(struct vm_area_struct *vma)
1750-
{
1751-
struct inode *bd_inode = bdev_file_inode(vma->vm_file);
1752-
struct block_device *bdev = I_BDEV(bd_inode);
1753-
1754-
inode_lock(bd_inode);
1755-
bdev->bd_map_count--;
1756-
inode_unlock(bd_inode);
1757-
}
1758-
17591739
static const struct vm_operations_struct blkdev_dax_vm_ops = {
1760-
.open = blkdev_vm_open,
1761-
.close = blkdev_vm_close,
17621740
.fault = blkdev_dax_fault,
17631741
.pmd_fault = blkdev_dax_pmd_fault,
17641742
.pfn_mkwrite = blkdev_dax_fault,
17651743
};
17661744

17671745
static const struct vm_operations_struct blkdev_default_vm_ops = {
1768-
.open = blkdev_vm_open,
1769-
.close = blkdev_vm_close,
17701746
.fault = filemap_fault,
17711747
.map_pages = filemap_map_pages,
17721748
};
17731749

17741750
static int blkdev_mmap(struct file *file, struct vm_area_struct *vma)
17751751
{
17761752
struct inode *bd_inode = bdev_file_inode(file);
1777-
struct block_device *bdev = I_BDEV(bd_inode);
17781753

17791754
file_accessed(file);
1780-
inode_lock(bd_inode);
1781-
bdev->bd_map_count++;
17821755
if (IS_DAX(bd_inode)) {
17831756
vma->vm_ops = &blkdev_dax_vm_ops;
17841757
vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE;
17851758
} else {
17861759
vma->vm_ops = &blkdev_default_vm_ops;
17871760
}
1788-
inode_unlock(bd_inode);
17891761

17901762
return 0;
17911763
}

include/linux/fs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,6 @@ struct block_device {
484484
int bd_fsfreeze_count;
485485
/* Mutex for freeze */
486486
struct mutex bd_fsfreeze_mutex;
487-
#ifdef CONFIG_FS_DAX
488-
int bd_map_count;
489-
#endif
490487
};
491488

492489
/*

include/uapi/linux/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ struct fsxattr {
222222
#define BLKSECDISCARD _IO(0x12,125)
223223
#define BLKROTATIONAL _IO(0x12,126)
224224
#define BLKZEROOUT _IO(0x12,127)
225-
#define BLKDAXSET _IO(0x12,128)
226225
#define BLKDAXGET _IO(0x12,129)
227226

228227
#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */

0 commit comments

Comments
 (0)