[PATCH] bad_inode: add missing i_op initializers for fileattr_get/_set

From: Ritesh Harjani
Date: Wed Jan 12 2022 - 10:50:41 EST


Let's bring inode_operations in sync for bad_inode_ops.
Some of the reasons are listed here [1]. But mostly it is
just for completeness sake I think.

This patch also removes some of the whitespaces at the end of line
which is due to my editor config settings for kernel work.

[1]: https://lore.kernel.org/lkml/1473708559-12714-2-git-send-email-mszeredi@xxxxxxxxxx/

Signed-off-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
---
fs/bad_inode.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 12b8fdcc445b..08d5e44316cc 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -160,6 +160,17 @@ static int bad_inode_set_acl(struct user_namespace *mnt_userns,
return -EIO;
}

+static int bad_inode_fileattr_set(struct user_namespace *mnt_userns,
+ struct dentry *dentry, struct fileattr *fa)
+{
+ return -EIO;
+}
+
+static int bad_inode_fileattr_get(struct dentry *dentry, struct fileattr *fa)
+{
+ return -EIO;
+}
+
static const struct inode_operations bad_inode_ops =
{
.create = bad_inode_create,
@@ -183,18 +194,19 @@ static const struct inode_operations bad_inode_ops =
.atomic_open = bad_inode_atomic_open,
.tmpfile = bad_inode_tmpfile,
.set_acl = bad_inode_set_acl,
+ .fileattr_set = bad_inode_fileattr_set,
+ .fileattr_get = bad_inode_fileattr_get,
};

-
/*
* When a filesystem is unable to read an inode due to an I/O error in
* its read_inode() function, it can call make_bad_inode() to return a
- * set of stubs which will return EIO errors as required.
+ * set of stubs which will return EIO errors as required.
*
* We only need to do limited initialisation: all other fields are
* preinitialised to zero automatically.
*/
-
+
/**
* make_bad_inode - mark an inode bad due to an I/O error
* @inode: Inode to mark bad
@@ -203,7 +215,7 @@ static const struct inode_operations bad_inode_ops =
* failure this function makes the inode "bad" and causes I/O operations
* on it to fail from this point on.
*/
-
+
void make_bad_inode(struct inode *inode)
{
remove_inode_hash(inode);
@@ -211,9 +223,9 @@ void make_bad_inode(struct inode *inode)
inode->i_mode = S_IFREG;
inode->i_atime = inode->i_mtime = inode->i_ctime =
current_time(inode);
- inode->i_op = &bad_inode_ops;
+ inode->i_op = &bad_inode_ops;
inode->i_opflags &= ~IOP_XATTR;
- inode->i_fop = &bad_file_ops;
+ inode->i_fop = &bad_file_ops;
}
EXPORT_SYMBOL(make_bad_inode);

@@ -222,17 +234,17 @@ EXPORT_SYMBOL(make_bad_inode);
* &bad_inode_ops to cover the case of invalidated inodes as well as
* those created by make_bad_inode() above.
*/
-
+
/**
* is_bad_inode - is an inode errored
* @inode: inode to test
*
* Returns true if the inode in question has been marked as bad.
*/
-
+
bool is_bad_inode(struct inode *inode)
{
- return (inode->i_op == &bad_inode_ops);
+ return (inode->i_op == &bad_inode_ops);
}

EXPORT_SYMBOL(is_bad_inode);
--
2.31.1