* [PATCH] fs: remove the special !CONFIG_BLOCK def_blk_fops
@ 2023-05-08 14:44 Christoph Hellwig
2023-05-19 5:38 ` Christoph Hellwig
2023-05-20 1:49 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-05-08 14:44 UTC (permalink / raw)
To: axboe; +Cc: dhowells, linux-block, linux-fsdevel
def_blk_fops always returns -ENODEV, which dosn't match the return value
of a non-existing block device with CONFIG_BLOCK, which is -ENXIO.
Just remove the extra implementation and fall back to the default
no_open_fops that always returns -ENXIO.
Fixes: 9361401eb761 ("[PATCH] BLOCK: Make it possible to disable the block layer [try #6]")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/Makefile | 10 ++--------
fs/inode.c | 3 ++-
fs/no-block.c | 19 -------------------
3 files changed, 4 insertions(+), 28 deletions(-)
delete mode 100644 fs/no-block.c
diff --git a/fs/Makefile b/fs/Makefile
index 834f1c3dba4642..4709eba1303c60 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -17,14 +17,8 @@ obj-y := open.o read_write.o file_table.o super.o \
fs_types.o fs_context.o fs_parser.o fsopen.o init.o \
kernel_read_file.o mnt_idmapping.o remap_range.o
-ifeq ($(CONFIG_BLOCK),y)
-obj-y += buffer.o mpage.o
-else
-obj-y += no-block.o
-endif
-
-obj-$(CONFIG_PROC_FS) += proc_namespace.o
-
+obj-$(CONFIG_BLOCK) += buffer.o mpage.o
+obj-$(CONFIG_PROC_FS) += proc_namespace.o
obj-$(CONFIG_LEGACY_DIRECT_IO) += direct-io.o
obj-y += notify/
obj-$(CONFIG_EPOLL) += eventpoll.o
diff --git a/fs/inode.c b/fs/inode.c
index 577799b7855f6f..4d6a1544e95b7f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2264,7 +2264,8 @@ void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
inode->i_fop = &def_chr_fops;
inode->i_rdev = rdev;
} else if (S_ISBLK(mode)) {
- inode->i_fop = &def_blk_fops;
+ if (IS_ENABLED(CONFIG_BLOCK))
+ inode->i_fop = &def_blk_fops;
inode->i_rdev = rdev;
} else if (S_ISFIFO(mode))
inode->i_fop = &pipefifo_fops;
diff --git a/fs/no-block.c b/fs/no-block.c
deleted file mode 100644
index 481c0f0ab4bd2c..00000000000000
--- a/fs/no-block.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/* no-block.c: implementation of routines required for non-BLOCK configuration
- *
- * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- */
-
-#include <linux/kernel.h>
-#include <linux/fs.h>
-
-static int no_blkdev_open(struct inode * inode, struct file * filp)
-{
- return -ENODEV;
-}
-
-const struct file_operations def_blk_fops = {
- .open = no_blkdev_open,
- .llseek = noop_llseek,
-};
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] fs: remove the special !CONFIG_BLOCK def_blk_fops
2023-05-08 14:44 [PATCH] fs: remove the special !CONFIG_BLOCK def_blk_fops Christoph Hellwig
@ 2023-05-19 5:38 ` Christoph Hellwig
2023-05-20 1:49 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-05-19 5:38 UTC (permalink / raw)
To: axboe; +Cc: dhowells, linux-block, linux-fsdevel
Jens, can you pick this one up?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: remove the special !CONFIG_BLOCK def_blk_fops
2023-05-08 14:44 [PATCH] fs: remove the special !CONFIG_BLOCK def_blk_fops Christoph Hellwig
2023-05-19 5:38 ` Christoph Hellwig
@ 2023-05-20 1:49 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-05-20 1:49 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: dhowells, linux-block, linux-fsdevel
On Mon, 08 May 2023 07:44:05 -0700, Christoph Hellwig wrote:
> def_blk_fops always returns -ENODEV, which dosn't match the return value
> of a non-existing block device with CONFIG_BLOCK, which is -ENXIO.
> Just remove the extra implementation and fall back to the default
> no_open_fops that always returns -ENXIO.
>
>
Applied, thanks!
[1/1] fs: remove the special !CONFIG_BLOCK def_blk_fops
commit: bda2795a630b2f6c417675bfbf4d90ef7503dfc7
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-20 1:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-08 14:44 [PATCH] fs: remove the special !CONFIG_BLOCK def_blk_fops Christoph Hellwig
2023-05-19 5:38 ` Christoph Hellwig
2023-05-20 1:49 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).