mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] dcache: add missing linux/list.h include
@ 2016-01-29 14:06 yegorslists
  2016-01-29 14:06 ` [PATCH 2/2] fs: add super_operations infrastructure yegorslists
  2016-02-01  8:18 ` [PATCH 1/2] dcache: add missing linux/list.h include Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: yegorslists @ 2016-01-29 14:06 UTC (permalink / raw)
  To: barebox

From: Yegor Yefremov <yegorslists@googlemail.com>

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 include/linux/dcache.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 9f33e75..dfb4667 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -10,6 +10,7 @@
  * with heavy changes by Linus Torvalds
  */
 
+#include <linux/list.h>
 #include <linux/spinlock.h>
 
 #define IS_ROOT(x) ((x) == (x)->d_parent)
-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] fs: add super_operations infrastructure
  2016-01-29 14:06 [PATCH 1/2] dcache: add missing linux/list.h include yegorslists
@ 2016-01-29 14:06 ` yegorslists
  2016-02-01  8:47   ` Sascha Hauer
  2016-02-01  8:18 ` [PATCH 1/2] dcache: add missing linux/list.h include Sascha Hauer
  1 sibling, 1 reply; 5+ messages in thread
From: yegorslists @ 2016-01-29 14:06 UTC (permalink / raw)
  To: barebox

From: Yegor Yefremov <yegorslists@googlemail.com>

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 fs/Makefile        |  1 +
 fs/inode.c         | 34 ++++++++++++++++++++++++++++++++++
 fs/ubifs/super.c   | 26 +++++++++++---------------
 include/linux/fs.h |  6 ++++++
 4 files changed, 52 insertions(+), 15 deletions(-)
 create mode 100644 fs/inode.c

diff --git a/fs/Makefile b/fs/Makefile
index 7896e38..320e6fa 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -5,6 +5,7 @@ obj-y			+= devfs-core.o
 obj-$(CONFIG_FS_DEVFS)	+= devfs.o
 obj-$(CONFIG_FS_FAT)	+= fat/
 obj-y	+= fs.o
+obj-y	+= inode.o
 obj-$(CONFIG_FS_UBIFS)	+= ubifs/
 obj-$(CONFIG_FS_TFTP)	+= tftp.o
 obj-$(CONFIG_FS_OMAP4_USBBOOT)	+= omap4_usbbootfs.o
diff --git a/fs/inode.c b/fs/inode.c
new file mode 100644
index 0000000..f9b1b63
--- /dev/null
+++ b/fs/inode.c
@@ -0,0 +1,34 @@
+/*
+ * (C) 1997 Linus Torvalds
+ * (C) 1999 Andrea Arcangeli <andrea@suse.de> (dynamic inode allocation)
+ */
+
+#include <linux/mount.h>
+
+/**
+ * iget_locked - obtain an inode from a mounted file system
+ * @sb:		super block of file system
+ * @ino:	inode number to get
+ *
+ * Search for the inode specified by @ino in the inode cache and if present
+ * return it with an increased reference count. This is for file systems
+ * where the inode number is sufficient for unique identification of an inode.
+ *
+ * If the inode is not in cache, allocate a new inode and return it locked,
+ * hashed, and with the I_NEW flag set.  The file system gets to fill it in
+ * before unlocking it via unlock_new_inode().
+ */
+struct inode *iget_locked(struct super_block *sb, unsigned long ino)
+{
+	struct inode *inode;
+
+	inode = sb->s_op->alloc_inode(sb);
+	if (inode) {
+		inode->i_ino = ino;
+		inode->i_sb = sb;
+		list_add(&inode->i_sb_list, &sb->s_inodes);
+		inode->i_state = I_SYNC | I_NEW;
+	}
+
+	return inode;
+}
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index b45240d..10f922a 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -79,21 +79,6 @@ static int validate_inode(struct ubifs_info *c, const struct inode *inode)
 	return err;
 }
 
-struct inode *iget_locked(struct super_block *sb, unsigned long ino)
-{
-	struct inode *inode;
-
-	inode = (struct inode *)malloc(sizeof(struct ubifs_inode));
-	if (inode) {
-		inode->i_ino = ino;
-		inode->i_sb = sb;
-		list_add(&inode->i_sb_list, &sb->s_inodes);
-		inode->i_state = I_SYNC | I_NEW;
-	}
-
-	return inode;
-}
-
 int ubifs_iput(struct inode *inode)
 {
 	list_del_init(&inode->i_sb_list);
@@ -814,6 +799,15 @@ void ubifs_umount(struct ubifs_info *c)
 	ubifs_debugging_exit(c);
 }
 
+static struct inode *ubifs_alloc_inode(struct super_block *sb)
+{
+	return (struct inode *)malloc(sizeof(struct ubifs_inode));
+};
+
+const struct super_operations ubifs_super_operations = {
+	.alloc_inode   = ubifs_alloc_inode,
+};
+
 struct super_block *ubifs_get_super(struct device_d *dev, struct ubi_volume_desc *ubi, int silent)
 {
 	struct super_block *sb;
@@ -888,6 +882,8 @@ struct super_block *ubifs_get_super(struct device_d *dev, struct ubi_volume_desc
 		return ERR_PTR(-EROFS);
 	}
 
+	sb->s_op = &ubifs_super_operations;
+
 	mutex_lock(&c->umount_mutex);
 	err = mount_ubifs(c);
 	if (err) {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7e9886a..9aec052 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -112,6 +112,10 @@ struct inode {
 	void			*i_private; /* fs or device private pointer */
 };
 
+struct super_operations {
+        struct inode *(*alloc_inode)(struct super_block *sb);
+};
+
 struct super_block {
 	struct list_head	s_list;		/* Keep this first */
 	dev_t			s_dev;		/* search index; _not_ kdev_t */
@@ -361,4 +365,6 @@ struct file {
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
 #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME)
 
+extern struct inode * iget_locked(struct super_block *, unsigned long);
+
 #endif /* _LINUX_FS_H */
-- 
2.1.4


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dcache: add missing linux/list.h include
  2016-01-29 14:06 [PATCH 1/2] dcache: add missing linux/list.h include yegorslists
  2016-01-29 14:06 ` [PATCH 2/2] fs: add super_operations infrastructure yegorslists
@ 2016-02-01  8:18 ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2016-02-01  8:18 UTC (permalink / raw)
  To: yegorslists; +Cc: barebox

On Fri, Jan 29, 2016 at 03:06:20PM +0100, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  include/linux/dcache.h | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] fs: add super_operations infrastructure
  2016-01-29 14:06 ` [PATCH 2/2] fs: add super_operations infrastructure yegorslists
@ 2016-02-01  8:47   ` Sascha Hauer
  2016-02-02  7:27     ` Yegor Yefremov
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2016-02-01  8:47 UTC (permalink / raw)
  To: yegorslists; +Cc: barebox

On Fri, Jan 29, 2016 at 03:06:21PM +0100, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  fs/Makefile        |  1 +
>  fs/inode.c         | 34 ++++++++++++++++++++++++++++++++++
>  fs/ubifs/super.c   | 26 +++++++++++---------------
>  include/linux/fs.h |  6 ++++++
>  4 files changed, 52 insertions(+), 15 deletions(-)
>  create mode 100644 fs/inode.c
> 
> diff --git a/fs/Makefile b/fs/Makefile
> index 7896e38..320e6fa 100644
> --- a/fs/Makefile
> +++ b/fs/Makefile
> @@ -5,6 +5,7 @@ obj-y			+= devfs-core.o
>  obj-$(CONFIG_FS_DEVFS)	+= devfs.o
>  obj-$(CONFIG_FS_FAT)	+= fat/
>  obj-y	+= fs.o
> +obj-y	+= inode.o
>  obj-$(CONFIG_FS_UBIFS)	+= ubifs/
>  obj-$(CONFIG_FS_TFTP)	+= tftp.o
>  obj-$(CONFIG_FS_OMAP4_USBBOOT)	+= omap4_usbbootfs.o
> diff --git a/fs/inode.c b/fs/inode.c
> new file mode 100644
> index 0000000..f9b1b63
> --- /dev/null
> +++ b/fs/inode.c
> @@ -0,0 +1,34 @@
> +/*
> + * (C) 1997 Linus Torvalds
> + * (C) 1999 Andrea Arcangeli <andrea@suse.de> (dynamic inode allocation)
> + */
> +
> +#include <linux/mount.h>
> +
> +/**
> + * iget_locked - obtain an inode from a mounted file system
> + * @sb:		super block of file system
> + * @ino:	inode number to get
> + *
> + * Search for the inode specified by @ino in the inode cache and if present
> + * return it with an increased reference count. This is for file systems
> + * where the inode number is sufficient for unique identification of an inode.
> + *
> + * If the inode is not in cache, allocate a new inode and return it locked,
> + * hashed, and with the I_NEW flag set.  The file system gets to fill it in
> + * before unlocking it via unlock_new_inode().
> + */
> +struct inode *iget_locked(struct super_block *sb, unsigned long ino)
> +{
> +	struct inode *inode;
> +
> +	inode = sb->s_op->alloc_inode(sb);
> +	if (inode) {
> +		inode->i_ino = ino;
> +		inode->i_sb = sb;
> +		list_add(&inode->i_sb_list, &sb->s_inodes);
> +		inode->i_state = I_SYNC | I_NEW;
> +	}
> +
> +	return inode;
> +}

Let's stop here, the border has been crossed. We can introduce no-op
wrappers for functions which do not have any meaning in barebox
(spinlocks and the like), we can introduce convenience wrappers for
functions that have a different name in barebox (like kmalloc), but
please let's not introduce functions which do more complicated things
which depend on structures being ordered the way they are in the Linux
kernel. I'm really afraid this way we merge more and more code from
Linux that doesn't really make sense in the barebox context and that we
have to keep code in the filesystem drivers just to make the parallel
universe of the Linux wrappers happy. That's a can of worms I don't want
to open.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] fs: add super_operations infrastructure
  2016-02-01  8:47   ` Sascha Hauer
@ 2016-02-02  7:27     ` Yegor Yefremov
  0 siblings, 0 replies; 5+ messages in thread
From: Yegor Yefremov @ 2016-02-02  7:27 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Mon, Feb 1, 2016 at 9:47 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Fri, Jan 29, 2016 at 03:06:21PM +0100, yegorslists@googlemail.com wrote:
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> ---
>>  fs/Makefile        |  1 +
>>  fs/inode.c         | 34 ++++++++++++++++++++++++++++++++++
>>  fs/ubifs/super.c   | 26 +++++++++++---------------
>>  include/linux/fs.h |  6 ++++++
>>  4 files changed, 52 insertions(+), 15 deletions(-)
>>  create mode 100644 fs/inode.c
>>
>> diff --git a/fs/Makefile b/fs/Makefile
>> index 7896e38..320e6fa 100644
>> --- a/fs/Makefile
>> +++ b/fs/Makefile
>> @@ -5,6 +5,7 @@ obj-y                 += devfs-core.o
>>  obj-$(CONFIG_FS_DEVFS)       += devfs.o
>>  obj-$(CONFIG_FS_FAT) += fat/
>>  obj-y        += fs.o
>> +obj-y        += inode.o
>>  obj-$(CONFIG_FS_UBIFS)       += ubifs/
>>  obj-$(CONFIG_FS_TFTP)        += tftp.o
>>  obj-$(CONFIG_FS_OMAP4_USBBOOT)       += omap4_usbbootfs.o
>> diff --git a/fs/inode.c b/fs/inode.c
>> new file mode 100644
>> index 0000000..f9b1b63
>> --- /dev/null
>> +++ b/fs/inode.c
>> @@ -0,0 +1,34 @@
>> +/*
>> + * (C) 1997 Linus Torvalds
>> + * (C) 1999 Andrea Arcangeli <andrea@suse.de> (dynamic inode allocation)
>> + */
>> +
>> +#include <linux/mount.h>
>> +
>> +/**
>> + * iget_locked - obtain an inode from a mounted file system
>> + * @sb:              super block of file system
>> + * @ino:     inode number to get
>> + *
>> + * Search for the inode specified by @ino in the inode cache and if present
>> + * return it with an increased reference count. This is for file systems
>> + * where the inode number is sufficient for unique identification of an inode.
>> + *
>> + * If the inode is not in cache, allocate a new inode and return it locked,
>> + * hashed, and with the I_NEW flag set.  The file system gets to fill it in
>> + * before unlocking it via unlock_new_inode().
>> + */
>> +struct inode *iget_locked(struct super_block *sb, unsigned long ino)
>> +{
>> +     struct inode *inode;
>> +
>> +     inode = sb->s_op->alloc_inode(sb);
>> +     if (inode) {
>> +             inode->i_ino = ino;
>> +             inode->i_sb = sb;
>> +             list_add(&inode->i_sb_list, &sb->s_inodes);
>> +             inode->i_state = I_SYNC | I_NEW;
>> +     }
>> +
>> +     return inode;
>> +}
>
> Let's stop here, the border has been crossed. We can introduce no-op
> wrappers for functions which do not have any meaning in barebox
> (spinlocks and the like), we can introduce convenience wrappers for
> functions that have a different name in barebox (like kmalloc), but
> please let's not introduce functions which do more complicated things
> which depend on structures being ordered the way they are in the Linux
> kernel. I'm really afraid this way we merge more and more code from
> Linux that doesn't really make sense in the barebox context and that we
> have to keep code in the filesystem drivers just to make the parallel
> universe of the Linux wrappers happy. That's a can of worms I don't want
> to open.

OK. We'll see, what can be generalized between ubifs and squashfs
after I'm finished.

Yegor

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-02  7:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-29 14:06 [PATCH 1/2] dcache: add missing linux/list.h include yegorslists
2016-01-29 14:06 ` [PATCH 2/2] fs: add super_operations infrastructure yegorslists
2016-02-01  8:47   ` Sascha Hauer
2016-02-02  7:27     ` Yegor Yefremov
2016-02-01  8:18 ` [PATCH 1/2] dcache: add missing linux/list.h include Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox