From patchwork Mon Jul 22 01:23:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11051289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3852813AC for ; Mon, 22 Jul 2019 01:24:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 222DF26E4A for ; Mon, 22 Jul 2019 01:24:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 151D8284A3; Mon, 22 Jul 2019 01:24:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B4DD526E4A for ; Mon, 22 Jul 2019 01:24:01 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 7D7F321FCF3; Sun, 21 Jul 2019 18:24:00 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BA1AC21F4F7 for ; Sun, 21 Jul 2019 18:23:58 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id CB9EA275; Sun, 21 Jul 2019 21:23:55 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id C305E1F8; Sun, 21 Jul 2019 21:23:55 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown , Shaun Tancheff , Li Dongyang , Artem Blagodarenko , Yang Sheng Date: Sun, 21 Jul 2019 21:23:33 -0400 Message-Id: <1563758631-29550-5-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1563758631-29550-1-git-send-email-jsimmons@infradead.org> References: <1563758631-29550-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 04/22] ext4: export inode management X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make ext4_delete_entry() exportable for osd-ldiskfs. Also add exportable ext4_create_inode(). Signed-off-by: James Simmons --- fs/ext4/ext4.h | 6 ++++++ fs/ext4/namei.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) 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