diff mbox series

[04/22] ext4: export inode management

Message ID 1563758631-29550-5-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series ldiskfs patches against 5.2-rc2+ | expand

Commit Message

James Simmons July 22, 2019, 1:23 a.m. UTC
Make ext4_delete_entry() exportable for osd-ldiskfs. Also add
exportable ext4_create_inode().

Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/ext4/ext4.h  |  6 ++++++
 fs/ext4/namei.c | 30 ++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)

Comments

NeilBrown July 22, 2019, 4:34 a.m. UTC | #1
On Sun, Jul 21 2019, James Simmons wrote:

> Make ext4_delete_entry() exportable for osd-ldiskfs. Also add
> exportable ext4_create_inode().

Why can't lustre use vfs_unlink like everyone else?  And vfs_mknod()?
My hope is that what we land upstream will use generic interfaces only.
If there is something that osd needs to do that the generic interfaces
cannot support, then we need to look at how to add that to the generic
interface.

NeilBrown
Oleg Drokin July 22, 2019, 7:16 a.m. UTC | #2
> On Jul 22, 2019, at 12:34 AM, NeilBrown <neilb@suse.com> wrote:
> 
> On Sun, Jul 21 2019, James Simmons wrote:
> 
>> Make ext4_delete_entry() exportable for osd-ldiskfs. Also add
>> exportable ext4_create_inode().
> 
> Why can't lustre use vfs_unlink like everyone else?  And vfs_mknod()?
> My hope is that what we land upstream will use generic interfaces only.
> If there is something that osd needs to do that the generic interfaces
> cannot support, then we need to look at how to add that to the generic
> interface.

That’s probably going to be a tough thing to do. At times we need certain things
that are bad from vfs standpoint in general sense, but because we have various
outside guarantees from locking and such - we can still do them.

nothing precise comes to mind now, but I remember various games with
nlink count/moving and resurrecting such files.

We also have wider “transaction boundaries”. Where say normal via-vfs transaction
is metadata only, we can request certain data (from ext4 perspective, but metadata
from Lustre) to be part of a particular transaction.
diff mbox series

Patch

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 423ab4d..50f0c50 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2579,6 +2579,12 @@  extern int ext4_dirent_csum_verify(struct inode *inode,
 				   struct ext4_dir_entry *dirent);
 extern int ext4_orphan_add(handle_t *, struct inode *);
 extern int ext4_orphan_del(handle_t *, struct inode *);
+extern struct inode *ext4_create_inode(handle_t *handle,
+				       struct inode *dir, int mode,
+				       uid_t *owner);
+extern int ext4_delete_entry(handle_t *handle, struct inode * dir,
+			     struct ext4_dir_entry_2 *de_del,
+			     struct buffer_head *bh);
 extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 				__u32 start_minor_hash, __u32 *next_hash);
 extern int ext4_search_dir(struct buffer_head *bh,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a52b311..a42a2db 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2459,10 +2459,9 @@  int ext4_generic_delete_entry(handle_t *handle,
 	return -ENOENT;
 }
 
-static int ext4_delete_entry(handle_t *handle,
-			     struct inode *dir,
-			     struct ext4_dir_entry_2 *de_del,
-			     struct buffer_head *bh)
+int ext4_delete_entry(handle_t *handle, struct inode *dir,
+		      struct ext4_dir_entry_2 *de_del,
+		      struct buffer_head *bh)
 {
 	int err, csum_size = 0;
 
@@ -2499,6 +2498,7 @@  static int ext4_delete_entry(handle_t *handle,
 		ext4_std_error(dir->i_sb, err);
 	return err;
 }
+EXPORT_SYMBOL(ext4_delete_entry);
 
 /*
  * Set directory link count to 1 if nlinks > EXT4_LINK_MAX, or if nlinks == 2
@@ -2545,6 +2545,28 @@  static int ext4_add_nondir(handle_t *handle,
 	return err;
 }
 
+/* Return locked inode, then the caller can modify the inode's states/flags
+ * before others finding it. The caller should unlock the inode by itself.
+ */
+struct inode *ext4_create_inode(handle_t *handle, struct inode *dir, int mode,
+				uid_t *owner)
+{
+	struct inode *inode;
+
+	inode = ext4_new_inode(handle, dir, mode, NULL, 0, owner, 0);
+	if (!IS_ERR(inode)) {
+		if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) {
+			inode->i_op = &ext4_special_inode_operations;
+		} else {
+			inode->i_op = &ext4_file_inode_operations;
+			inode->i_fop = &ext4_file_operations;
+			ext4_set_aops(inode);
+		}
+	}
+	return inode;
+}
+EXPORT_SYMBOL(ext4_create_inode);
+
 /*
  * By the time this is called, we already have created
  * the directory cache entry for the new file, but it