| Message ID | 20260512053625.2950900-7-hch@lst.de |
|---|---|
| State | Not Applicable |
| Headers | show |
| Series | [01/12] swap: remove the maxpages variable in sys_swapon | expand |
On 5/12/26 14:35, Christoph Hellwig wrote: > Make use of the abstractions we have. This is a preparation for > moving more special casing down into block/. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks OK to me. Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
On Tue, May 12, 2026 at 07:35:22AM +0200, Christoph Hellwig wrote: > Make use of the abstractions we have. This is a preparation for > moving more special casing down into block/. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Nice straightforward hoist. Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > block/fops.c | 6 ++++++ > mm/swapfile.c | 5 ----- > 2 files changed, 6 insertions(+), 5 deletions(-) > > diff --git a/block/fops.c b/block/fops.c > index bb6642b45937..453141801684 100644 > --- a/block/fops.c > +++ b/block/fops.c > @@ -949,6 +949,11 @@ static int blkdev_mmap_prepare(struct vm_area_desc *desc) > return generic_file_mmap_prepare(desc); > } > > +static int blkdev_swap_activate(struct file *file, struct swap_info_struct *sis) > +{ > + return add_swap_extent(sis, sis->max, 0); > +} > + > const struct file_operations def_blk_fops = { > .open = blkdev_open, > .release = blkdev_release, > @@ -965,6 +970,7 @@ const struct file_operations def_blk_fops = { > .splice_read = filemap_splice_read, > .splice_write = iter_file_splice_write, > .fallocate = blkdev_fallocate, > + .swap_activate = blkdev_swap_activate, > .uring_cmd = blkdev_uring_cmd, > .fop_flags = FOP_BUFFER_RASYNC, > }; > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 1b7fc03612f4..fbf11c8c5c69 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -2781,13 +2781,8 @@ EXPORT_SYMBOL_GPL(add_swap_extent); > static int setup_swap_extents(struct swap_info_struct *sis, > struct file *swap_file) > { > - struct address_space *mapping = swap_file->f_mapping; > - struct inode *inode = mapping->host; > int ret, error = 0; > > - if (S_ISBLK(inode->i_mode)) > - return add_swap_extent(sis, sis->max, 0); > - > if (swap_file->f_op->swap_activate) > ret = swap_file->f_op->swap_activate(swap_file, sis); > else > -- > 2.53.0 > >
On Mon, May 11, 2026 at 10:37 PM Christoph Hellwig <hch@lst.de> wrote: > > Make use of the abstractions we have. This is a preparation for > moving more special casing down into block/. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Chris Li <chrisl@kernel.org> Chris
diff --git a/block/fops.c b/block/fops.c index bb6642b45937..453141801684 100644 --- a/block/fops.c +++ b/block/fops.c @@ -949,6 +949,11 @@ static int blkdev_mmap_prepare(struct vm_area_desc *desc) return generic_file_mmap_prepare(desc); } +static int blkdev_swap_activate(struct file *file, struct swap_info_struct *sis) +{ + return add_swap_extent(sis, sis->max, 0); +} + const struct file_operations def_blk_fops = { .open = blkdev_open, .release = blkdev_release, @@ -965,6 +970,7 @@ const struct file_operations def_blk_fops = { .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = blkdev_fallocate, + .swap_activate = blkdev_swap_activate, .uring_cmd = blkdev_uring_cmd, .fop_flags = FOP_BUFFER_RASYNC, }; diff --git a/mm/swapfile.c b/mm/swapfile.c index 1b7fc03612f4..fbf11c8c5c69 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2781,13 +2781,8 @@ EXPORT_SYMBOL_GPL(add_swap_extent); static int setup_swap_extents(struct swap_info_struct *sis, struct file *swap_file) { - struct address_space *mapping = swap_file->f_mapping; - struct inode *inode = mapping->host; int ret, error = 0; - if (S_ISBLK(inode->i_mode)) - return add_swap_extent(sis, sis->max, 0); - if (swap_file->f_op->swap_activate) ret = swap_file->f_op->swap_activate(swap_file, sis); else
Make use of the abstractions we have. This is a preparation for moving more special casing down into block/. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/fops.c | 6 ++++++ mm/swapfile.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-)