From patchwork Sat Mar 7 10:10:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Zhong X-Patchwork-Id: 5959001 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2CA599F373 for ; Sat, 7 Mar 2015 10:10:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A00A820397 for ; Sat, 7 Mar 2015 10:10:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E394420392 for ; Sat, 7 Mar 2015 10:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755872AbbCGKKW (ORCPT ); Sat, 7 Mar 2015 05:10:22 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:25256 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755756AbbCGKKU (ORCPT ); Sat, 7 Mar 2015 05:10:20 -0500 Received: from epcpsbgx1.samsung.com (u161.gpu120.samsung.co.kr [203.254.230.161]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKU00JGX6X6KQ00@mailout3.samsung.com> for linux-fsdevel@vger.kernel.org; Sat, 07 Mar 2015 19:10:18 +0900 (KST) X-AuditID: cbfee6a1-f799b6d000003ba9-9d-54face8ab463 Received: from epmailer01 ( [203.254.219.141]) by epcpsbgx1.samsung.com (EPCPMTA) with SMTP id 1B.9D.15273.A8ECAF45; Sat, 07 Mar 2015 19:10:18 +0900 (KST) Date: Sat, 07 Mar 2015 10:10:18 +0000 (GMT) From: Yuan Zhong Subject: [f2fs-dev] [PATCH 3/3] f2fs:use enum dentrt_ptr type to replace constant use To: Jaegeuk Kim Cc: "linux-kernel@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-fsdevel@vger.kernel.org" Reply-to: yuan.mark.zhong@samsung.com MIME-version: 1.0 X-MTR: 20150307100915023@yuan.mark.zhong Msgkey: 20150307100915023@yuan.mark.zhong X-EPLocale: en_US.windows-1252 X-Priority: 3 X-EPWebmail-Msg-Type: personal X-EPWebmail-Reply-Demand: 0 X-EPApproval-Locale: X-EPHeader: ML X-MLAttribute: X-RootMTR: 20150307100915023@yuan.mark.zhong X-ParentMTR: X-ArchiveUser: X-CPGSPASS: N X-ConfirmMail: N,general Content-transfer-encoding: base64 Content-type: text/plain; charset=windows-1252 MIME-version: 1.0 Message-id: <1592448705.458641425723017011.JavaMail.weblogic@epmlwas08b> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsVy+t/tXt2uc79CDObPVrbYs/ckiwOjx+dN cgGMUVw2Kak5mWWpRfp2CVwZl9a/YC84p1kxc10jawPjAY0uRk4OIQEtifc/HjKD2BICJhJH LtxjgrDFJC7cW88GUTOHUWLr2zAQm0VAReLIh3csIDabgL7EnX37GEFsYYFQiXONN9hBbBEB NYk9l7YA1XBxMAvcZJToOdIPtIADaJCqxPG1pSA1vAKCEidnPmGB2KUhsfP6MhaIuKZEY/93 Voi4nMSSqZeh7uGVmNH+lAUmPu3rGqibpSXOz9rACHPz4u+PoeL8Esdu74DqFZCYeuYgVI2u xOpZx9khbD6JNQvfssDU7zq1nBlm1/0tc6F6JSS2tjwBu4dZQFFiSvdDdgjbQOLIojms6H7h FfCQmLx0KfMERtlZSFKzkLTPQtKOrGYBI8sqRtHUguSC4qT0CkO94sTc4tK8dL3k/NxNjOB4 frZwB+OX89aHGAU4GJV4eF/M+hUixJpYVlyZe4hRgoNZSYT3VRdQiDclsbIqtSg/vqg0J7X4 EKM0B4uSOO//c7khQgLpiSWp2ampBalFMFkmDk6pBsaqtr9u1sE6U0PjS8/7XiyePzW38Y64 kc7D4MPr/2/YMLmw5dr3ltCsdLemspmrp3w4/PTEDfWPLi8CdFZy2156Umw682f6cl29Uw2c W65neHNx5cs8O5bp/v/FLeFXJ8+nMYpHOwk2nGtifCT/vGd2w5aup9PLJfcmyHkyWNpkLU9j jOatuaDEUpyRaKjFXFScCAATlwQo4wIAAA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function make_dentry_ptr has an argument 'int type'. This argument is used to distinguish 'block dentry' and 'inline dentry'. We used 1 and 2 as the type. To make code more readable, we use enum type to replace constant use. Signed-off-by: Yuan Zhong --- fs/f2fs/dir.c | 8 ++++---- fs/f2fs/f2fs.h | 8 +++++++- fs/f2fs/inline.c | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) -- 1.7.9.5 diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 590aeef..c39a18f 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -99,7 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, dentry_blk = (struct f2fs_dentry_block *)kmap(dentry_page); - make_dentry_ptr(&d, (void *)dentry_blk, 1); + make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK); de = find_target_dentry(name, max_slots, &d); if (de) @@ -360,7 +360,7 @@ static int make_empty_dir(struct inode *inode, dentry_blk = kmap_atomic(dentry_page); - make_dentry_ptr(&d, (void *)dentry_blk, 1); + make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK); do_make_empty_dir(inode, parent, &d); kunmap_atomic(dentry_blk); @@ -571,7 +571,7 @@ add_dentry: goto fail; } - make_dentry_ptr(&d, (void *)dentry_blk, 1); + make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK); f2fs_update_dentry(inode, &d, name, dentry_hash, bit_pos); set_page_dirty(dentry_page); @@ -782,7 +782,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) dentry_blk = kmap(dentry_page); - make_dentry_ptr(&d, (void *)dentry_blk, 1); + make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_BLOCK); if (f2fs_fill_dentries(ctx, &d, n * NR_DENTRY_IN_BLOCK)) goto stop; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 511d6cd..31b440e 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -236,10 +236,16 @@ struct f2fs_dentry_ptr { int max; }; +enum { + DENTRY_PTR_TYPE_BLOCK = 1, + DENTRY_PTR_TYPE_INLNE, + DENTRY_PTR_TYPE_MAX +}; + static inline void make_dentry_ptr(struct f2fs_dentry_ptr *d, void *src, int type) { - if (type == 1) { + if (type == DENTRY_PTR_TYPE_BLOCK) { struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src; d->max = NR_DENTRY_IN_BLOCK; d->bitmap = &t->dentry_bitmap; diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 4ba9732..ee0984c 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -271,7 +271,7 @@ struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir, inline_dentry = inline_data_addr(ipage); - make_dentry_ptr(&d, (void *)inline_dentry, 2); + make_dentry_ptr(&d, (void *)inline_dentry, DENTRY_PTR_TYPE_INLNE); de = find_target_dentry(name, NULL, &d); unlock_page(ipage); @@ -315,7 +315,7 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent, dentry_blk = inline_data_addr(ipage); - make_dentry_ptr(&d, (void *)dentry_blk, 2); + make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_INLNE); do_make_empty_dir(inode, parent, &d); set_page_dirty(ipage); @@ -417,7 +417,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *name, f2fs_wait_on_page_writeback(ipage, NODE); name_hash = f2fs_dentry_hash(name); - make_dentry_ptr(&d, (void *)dentry_blk, 2); + make_dentry_ptr(&d, (void *)dentry_blk, DENTRY_PTR_TYPE_INLNE); f2fs_update_dentry(inode, &d, name, name_hash, bit_pos); set_page_dirty(ipage); @@ -507,7 +507,7 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx) inline_dentry = inline_data_addr(ipage); - make_dentry_ptr(&d, (void *)inline_dentry, 2); + make_dentry_ptr(&d, (void *)inline_dentry, DENTRY_PTR_TYPE_INLNE); if (!f2fs_fill_dentries(ctx, &d, 0)) ctx->pos = NR_INLINE_DENTRY;