mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 02/11] fs: Add destroy_inode callbacks to filesystems
Date: Mon, 15 Jun 2020 08:02:20 +0200	[thread overview]
Message-ID: <20200615060229.7533-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200615060229.7533-1-s.hauer@pengutronix.de>

Several filesystems rely on the default function which frees
the struct inode * rather than the filesystem specific inode
which the inode is embedded in. This works because the inode
is the first element in the filesystem specific inode. Let's
not depend on this behaviour and for clarity add the destroy_inode
callbacks to all filesystems.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/cramfs/cramfs.c     | 10 ++++++++++
 fs/devfs.c             |  8 ++++++++
 fs/nfs.c               |  8 ++++++++
 fs/ramfs.c             |  8 ++++++++
 fs/squashfs/squashfs.c | 10 +++++++++-
 5 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index 99cbdb920c..3ea6bd437e 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -333,6 +333,15 @@ static struct inode *cramfs_alloc_inode(struct super_block *sb)
 	return &info->i_inode;
 }
 
+static void cramfs_destroy_inode(struct inode *inode)
+{
+	struct cramfs_inode_info *info;
+
+	info = to_cramfs_inode_info(inode);
+
+	free(info);
+}
+
 static int cramfs_iterate(struct file *file, struct dir_context *ctx)
 {
 	struct dentry *dentry = file->f_path.dentry;
@@ -427,6 +436,7 @@ static const struct inode_operations cramfs_symlink_inode_operations =
 
 static const struct super_operations cramfs_ops = {
 	.alloc_inode = cramfs_alloc_inode,
+	.destroy_inode = cramfs_destroy_inode,
 };
 
 static int cramfs_probe(struct device_d *dev)
diff --git a/fs/devfs.c b/fs/devfs.c
index b503f277ac..df229cca48 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -200,6 +200,13 @@ static struct inode *devfs_alloc_inode(struct super_block *sb)
 	return &node->inode;
 }
 
+static void devfs_destroy_inode(struct inode *inode)
+{
+	struct devfs_inode *node = container_of(inode, struct devfs_inode, inode);
+
+	free(node);
+}
+
 static int devfs_iterate(struct file *file, struct dir_context *ctx)
 {
 	struct cdev *cdev;
@@ -314,6 +321,7 @@ static const struct inode_operations devfs_dir_inode_operations =
 
 static const struct super_operations devfs_ops = {
 	.alloc_inode = devfs_alloc_inode,
+	.destroy_inode = devfs_destroy_inode,
 };
 
 static int devfs_probe(struct device_d *dev)
diff --git a/fs/nfs.c b/fs/nfs.c
index 15ddab7915..6c4637281d 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1202,6 +1202,13 @@ static struct inode *nfs_alloc_inode(struct super_block *sb)
 	return &node->inode;
 }
 
+static void nfs_destroy_inode(struct inode *inode)
+{
+	struct nfs_inode *node = nfsi(inode);
+
+	free(node);
+}
+
 static const struct inode_operations nfs_file_inode_operations;
 static const struct file_operations nfs_dir_operations;
 static const struct inode_operations nfs_dir_inode_operations;
@@ -1273,6 +1280,7 @@ static const struct inode_operations nfs_dir_inode_operations =
 
 static const struct super_operations nfs_ops = {
 	.alloc_inode = nfs_alloc_inode,
+	.destroy_inode = nfs_destroy_inode,
 };
 
 static char *rootnfsopts;
diff --git a/fs/ramfs.c b/fs/ramfs.c
index 5328775ee0..341b6130de 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -396,8 +396,16 @@ static struct inode *ramfs_alloc_inode(struct super_block *sb)
 	return &node->inode;
 }
 
+static void ramfs_destroy_inode(struct inode *inode)
+{
+	struct ramfs_inode *node = to_ramfs_inode(inode);
+
+	free(node);
+}
+
 static const struct super_operations ramfs_ops = {
 	.alloc_inode = ramfs_alloc_inode,
+	.destroy_inode = ramfs_destroy_inode,
 };
 
 static int ramfs_probe(struct device_d *dev)
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index 38aff6d5b8..cb2d936ea4 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -76,8 +76,16 @@ static struct inode *squashfs_alloc_inode(struct super_block *sb)
 	return &node->vfs_inode;
 }
 
+static void squashfs_destroy_inode(struct inode *inode)
+{
+	struct squashfs_inode_info *node = squashfs_i(inode);
+
+	free(inode);
+}
+
 static const struct super_operations squashfs_super_ops = {
-        .alloc_inode = squashfs_alloc_inode,
+	.alloc_inode = squashfs_alloc_inode,
+	.destroy_inode = squashfs_destroy_inode,
 };
 
 static int squashfs_probe(struct device_d *dev)
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-06-15  6:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15  6:02 [PATCH 00/11] ramfs: Use dynamically sized chunks Sascha Hauer
2020-06-15  6:02 ` [PATCH 01/11] update list.h from Linux-5.7 Sascha Hauer
2020-06-15  6:02 ` Sascha Hauer [this message]
2020-06-15  6:02 ` [PATCH 03/11] fs: Make iput() accept NULL pointers Sascha Hauer
2020-06-15  6:02 ` [PATCH 04/11] fs: free inodes we no longer need Sascha Hauer
2020-08-03 22:02   ` Ahmad Fatoum
2020-08-10 11:13     ` Sascha Hauer
2020-06-15  6:02 ` [PATCH 05/11] digest: Drop usage of memmap Sascha Hauer
2020-06-15  6:02 ` [PATCH 06/11] fs: ramfs: Return -ENOSPC Sascha Hauer
2020-06-15  6:02 ` [PATCH 07/11] fs: ramfs: Drop dead code Sascha Hauer
2020-06-15  6:02 ` [PATCH 08/11] fs: ramfs: Use dynamically sized chunks Sascha Hauer
2020-07-02 14:28   ` Ahmad Fatoum
2020-07-05 14:14     ` Sascha Hauer
2020-06-15  6:02 ` [PATCH 09/11] fs: ramfs: Implement memmap Sascha Hauer
2020-06-15  6:02 ` [PATCH 10/11] libfile: copy_file: Fix calling discard_range Sascha Hauer
2020-06-15  6:02 ` [PATCH 11/11] libfile: copy_file: explicitly truncate to final size Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200615060229.7533-3-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox