Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646422 > unrolled thread

[PATCH 5/6] ubifs: Implement export_operations

Started byRichard Weinberger <richard@nod.at>
First post2017-05-21 22:30 +0200
Last post2017-05-23 11:00 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 5/6] ubifs: Implement export_operations Richard Weinberger <richard@nod.at> - 2017-05-21 22:30 +0200
    Re: [PATCH 5/6] ubifs: Implement export_operations Christoph Hellwig <hch@infradead.org> - 2017-05-23 10:40 +0200
      Re: [PATCH 5/6] ubifs: Implement export_operations Richard Weinberger <richard@nod.at> - 2017-05-23 10:50 +0200
        Re: [PATCH 5/6] ubifs: Implement export_operations Christoph Hellwig <hch@infradead.org> - 2017-05-23 10:50 +0200
          Re: [PATCH 5/6] ubifs: Implement export_operations Richard Weinberger <richard@nod.at> - 2017-05-23 11:00 +0200

#1646422 — [PATCH 5/6] ubifs: Implement export_operations

FromRichard Weinberger <richard@nod.at>
Date2017-05-21 22:30 +0200
Subject[PATCH 5/6] ubifs: Implement export_operations
Message-ID<tJFEe-46j-15@gated-at.bofh.it>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/super.c | 35 +++++++++++++++++++++++++++++++++++
 fs/ubifs/ubifs.h |  1 +
 2 files changed, 36 insertions(+)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 7560071534bf..4788420162b8 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2005,6 +2005,41 @@ const struct fscrypt_operations ubifs_crypt_operations = {
 };
 #endif
 
+static struct dentry *ubifs_get_parent(struct dentry *child)
+{
+	struct ubifs_inode *ui = ubifs_inode(d_inode(child));
+
+	return d_obtain_alias(ubifs_iget(child->d_sb, ui->parent_inum));
+}
+
+static struct inode *ubifs_nfs_get_inode(struct super_block *sb, uint64_t ino,
+					 uint32_t generation)
+{
+	return ubifs_iget(sb, ino);
+}
+
+static struct dentry *ubifs_fh_to_dentry(struct super_block *sb,
+					 struct fid *fid, int fh_len,
+					 int fh_type)
+{
+	return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+				    ubifs_nfs_get_inode);
+}
+
+static struct dentry *ubifs_fh_to_parent(struct super_block *sb,
+					 struct fid *fid, int fh_len,
+					 int fh_type)
+{
+	return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+				    ubifs_nfs_get_inode);
+}
+
+static const struct export_operations ubifs_export_ops = {
+	.get_parent = ubifs_get_parent,
+	.fh_to_dentry = ubifs_fh_to_dentry,
+	.fh_to_parent = ubifs_fh_to_parent,
+};
+
 static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct ubifs_info *c = sb->s_fs_info;
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 3c64481f4032..a728d6e3eb47 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -45,6 +45,7 @@
 #endif
 #include <linux/random.h>
 #include <linux/compat.h>
+#include <linux/exportfs.h>
 #include "ubifs-media.h"
 
 /* Version of this UBIFS implementation */
-- 
2.12.0

[toc] | [next] | [standalone]


#1647797

FromChristoph Hellwig <hch@infradead.org>
Date2017-05-23 10:40 +0200
Message-ID<tKdwe-Fm-23@gated-at.bofh.it>
In reply to#1646422
> +static struct inode *ubifs_nfs_get_inode(struct super_block *sb, uint64_t ino,
> +					 uint32_t generation)
> +{
> +	return ubifs_iget(sb, ino);
> +}

You need to maintain and check an inode generation counter for this
to be safe.

[toc] | [prev] | [next] | [standalone]


#1647813

FromRichard Weinberger <richard@nod.at>
Date2017-05-23 10:50 +0200
Message-ID<tKdFU-Jg-23@gated-at.bofh.it>
In reply to#1647797
Christoph,

Am 23.05.2017 um 10:39 schrieb Christoph Hellwig:
>> +static struct inode *ubifs_nfs_get_inode(struct super_block *sb, uint64_t ino,
>> +					 uint32_t generation)
>> +{
>> +	return ubifs_iget(sb, ino);
>> +}
> 
> You need to maintain and check an inode generation counter for this
> to be safe.

UBIFS has no inode generations, inodes simply can't wrap around.
We "handle" it like JFF2 does, we assumes that the NAND is long dead
before we reach the maximum inode number.

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1647814

FromChristoph Hellwig <hch@infradead.org>
Date2017-05-23 10:50 +0200
Message-ID<tKdFU-Jg-29@gated-at.bofh.it>
In reply to#1647813
On Tue, May 23, 2017 at 10:41:16AM +0200, Richard Weinberger wrote:
> UBIFS has no inode generations, inodes simply can't wrap around.
> We "handle" it like JFF2 does, we assumes that the NAND is long dead
> before we reach the maximum inode number.

So you never ever reuse an inode number once it's been unlinked and
the last opener went away?

If that is the case please add a comment explaining this next to
the get_inode helper.

[toc] | [prev] | [next] | [standalone]


#1647836

FromRichard Weinberger <richard@nod.at>
Date2017-05-23 11:00 +0200
Message-ID<tKdPA-N6-31@gated-at.bofh.it>
In reply to#1647814
Christoph,

Am 23.05.2017 um 10:48 schrieb Christoph Hellwig:
> On Tue, May 23, 2017 at 10:41:16AM +0200, Richard Weinberger wrote:
>> UBIFS has no inode generations, inodes simply can't wrap around.
>> We "handle" it like JFF2 does, we assumes that the NAND is long dead
>> before we reach the maximum inode number.
> 
> So you never ever reuse an inode number once it's been unlinked and
> the last opener went away?

Correct.

> If that is the case please add a comment explaining this next to
> the get_inode helper.

Will do.

Thanks,
//richard

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web