From patchwork Fri Mar 25 09:18:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Zhuoyu X-Patchwork-Id: 8669231 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3BD8BC0553 for ; Fri, 25 Mar 2016 09:19:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2112A20351 for ; Fri, 25 Mar 2016 09:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD7E620270 for ; Fri, 25 Mar 2016 09:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbcCYJTM (ORCPT ); Fri, 25 Mar 2016 05:19:12 -0400 Received: from m15-112.126.com ([220.181.15.112]:41004 "EHLO m15-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbcCYJTK (ORCPT ); Fri, 25 Mar 2016 05:19:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=uc/n9vU0ExuGFcT6BM p+b4eVKvlocCPhMElJgFxIhuw=; b=Lnwiips7sQw2J42GCDY5Kik5wwfB0D1D7m iXG1J5GiSybzdlpcX70QKV4vA6moT+4D+/QHsD7kwjZByiX42lkvmDiDIlCx33Ch dlmwUcG/CiBu1XRUg8P3EsKhM6w2oWNAJ/FVyy0YQPIODNDKVDXrQECAeesgFhzY 7dsjbrTJI= Received: from localhost (unknown [223.68.205.132]) by smtp2 (Coremail) with SMTP id DMmowEDpw0VyAvVWg6MVAA--.6728S3; Fri, 25 Mar 2016 17:18:43 +0800 (CST) From: Zhang Zhuoyu To: ceph-devel@vger.kernel.org Cc: sage@redhat.com, zyan@redhat.com, idryomov@gmail.com, linux-kernel@vger.kernel.org, Zhang Zhuoyu Subject: [PATCH v2 1/1] fs/ceph: make logical calculation functions return bool Date: Fri, 25 Mar 2016 05:18:39 -0400 Message-Id: <1458897519-19161-1-git-send-email-zhangzhuoyu@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DMmowEDpw0VyAvVWg6MVAA--.6728S3 X-Coremail-Antispam: 1Uf129KBjvJXoW3AFWUZrW3Kr18uFWUuF17Wrg_yoW3JryfpF W7JayUJw48JFy3WFWkJrs09rWrZrn3GFyIvrWrK34kGF1jqrW0qFnYq343tw1avFWSkF9F yF4UJry5Kw42yw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jvpBfUUUUU= X-Originating-IP: [223.68.205.132] X-CM-SenderInfo: xkhoz05221imiyy6ij2wof0z/1tbi9BQ31FYY5aN2+QAAsE Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 This patch makes serverl logical caculation functions return bool to improve readability due to these particular functions only using 0/1 as their return value. No functional change. --- v2 changelog: ceph_ino_compare() is used by ilookup5, and ilookup5() wants function pointer int (*test)(struct inode *, void *), so let ceph_ino_compare() keep its return value as int. Signed-off-by: Zhang Zhuoyu --- fs/ceph/cache.c | 2 +- fs/ceph/dir.c | 2 +- include/linux/ceph/ceph_frag.h | 12 ++++++------ include/linux/ceph/decode.h | 2 +- include/linux/ceph/osdmap.h | 6 +++--- include/linux/ceph/rados.h | 16 ++++++++-------- net/ceph/ceph_common.c | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c index 834f9f3..1f3a3f6 100644 --- a/fs/ceph/cache.c +++ b/fs/ceph/cache.c @@ -238,7 +238,7 @@ static void ceph_vfs_readpage_complete_unlock(struct page *page, void *data, int unlock_page(page); } -static inline int cache_valid(struct ceph_inode_info *ci) +static inline bool cache_valid(struct ceph_inode_info *ci) { return ((ceph_caps_issued(ci) & CEPH_CAP_FILE_CACHE) && (ci->i_fscache_gen == ci->i_rdcache_gen)); diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 26be849..7eed41e 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -584,7 +584,7 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, return dentry; } -static int is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) +static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) { return ceph_ino(inode) == CEPH_INO_ROOT && strncmp(dentry->d_name.name, ".ceph", 5) == 0; diff --git a/include/linux/ceph/ceph_frag.h b/include/linux/ceph/ceph_frag.h index 5babb8e..44e6067 100644 --- a/include/linux/ceph/ceph_frag.h +++ b/include/linux/ceph/ceph_frag.h @@ -40,11 +40,11 @@ static inline __u32 ceph_frag_mask_shift(__u32 f) return 24 - ceph_frag_bits(f); } -static inline int ceph_frag_contains_value(__u32 f, __u32 v) +static inline bool ceph_frag_contains_value(__u32 f, __u32 v) { return (v & ceph_frag_mask(f)) == ceph_frag_value(f); } -static inline int ceph_frag_contains_frag(__u32 f, __u32 sub) +static inline bool ceph_frag_contains_frag(__u32 f, __u32 sub) { /* is sub as specific as us, and contained by us? */ return ceph_frag_bits(sub) >= ceph_frag_bits(f) && @@ -56,12 +56,12 @@ static inline __u32 ceph_frag_parent(__u32 f) return ceph_frag_make(ceph_frag_bits(f) - 1, ceph_frag_value(f) & (ceph_frag_mask(f) << 1)); } -static inline int ceph_frag_is_left_child(__u32 f) +static inline bool ceph_frag_is_left_child(__u32 f) { return ceph_frag_bits(f) > 0 && (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 0; } -static inline int ceph_frag_is_right_child(__u32 f) +static inline bool ceph_frag_is_right_child(__u32 f) { return ceph_frag_bits(f) > 0 && (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 1; @@ -86,11 +86,11 @@ static inline __u32 ceph_frag_make_child(__u32 f, int by, int i) return ceph_frag_make(newbits, ceph_frag_value(f) | (i << (24 - newbits))); } -static inline int ceph_frag_is_leftmost(__u32 f) +static inline bool ceph_frag_is_leftmost(__u32 f) { return ceph_frag_value(f) == 0; } -static inline int ceph_frag_is_rightmost(__u32 f) +static inline bool ceph_frag_is_rightmost(__u32 f) { return ceph_frag_value(f) == ceph_frag_mask(f); } diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h index a6ef9cc..19e9932 100644 --- a/include/linux/ceph/decode.h +++ b/include/linux/ceph/decode.h @@ -47,7 +47,7 @@ static inline void ceph_decode_copy(void **p, void *pv, size_t n) /* * bounds check input. */ -static inline int ceph_has_room(void **p, void *end, size_t n) +static inline bool ceph_has_room(void **p, void *end, size_t n) { return end >= *p && n <= end - *p; } diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h index 561ea89..bbf66b7 100644 --- a/include/linux/ceph/osdmap.h +++ b/include/linux/ceph/osdmap.h @@ -137,19 +137,19 @@ static inline void ceph_oid_copy(struct ceph_object_id *dest, dest->name_len = src->name_len; } -static inline int ceph_osd_exists(struct ceph_osdmap *map, int osd) +static inline bool ceph_osd_exists(struct ceph_osdmap *map, int osd) { return osd >= 0 && osd < map->max_osd && (map->osd_state[osd] & CEPH_OSD_EXISTS); } -static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd) +static inline bool ceph_osd_is_up(struct ceph_osdmap *map, int osd) { return ceph_osd_exists(map, osd) && (map->osd_state[osd] & CEPH_OSD_UP); } -static inline int ceph_osd_is_down(struct ceph_osdmap *map, int osd) +static inline bool ceph_osd_is_down(struct ceph_osdmap *map, int osd) { return !ceph_osd_is_up(map, osd); } diff --git a/include/linux/ceph/rados.h b/include/linux/ceph/rados.h index 2f822dc..d6d4852 100644 --- a/include/linux/ceph/rados.h +++ b/include/linux/ceph/rados.h @@ -313,36 +313,36 @@ __CEPH_FORALL_OSD_OPS(GENERATE_ENUM_ENTRY) #undef GENERATE_ENUM_ENTRY }; -static inline int ceph_osd_op_type_lock(int op) +static inline bool ceph_osd_op_type_lock(int op) { return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK; } -static inline int ceph_osd_op_type_data(int op) +static inline bool ceph_osd_op_type_data(int op) { return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA; } -static inline int ceph_osd_op_type_attr(int op) +static inline bool ceph_osd_op_type_attr(int op) { return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR; } -static inline int ceph_osd_op_type_exec(int op) +static inline bool ceph_osd_op_type_exec(int op) { return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC; } -static inline int ceph_osd_op_type_pg(int op) +static inline bool ceph_osd_op_type_pg(int op) { return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG; } -static inline int ceph_osd_op_type_multi(int op) +static inline bool ceph_osd_op_type_multi(int op) { return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_MULTI; } -static inline int ceph_osd_op_mode_subop(int op) +static inline bool ceph_osd_op_mode_subop(int op) { return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB; } -static inline int ceph_osd_op_mode_read(int op) +static inline bool ceph_osd_op_mode_read(int op) { return (op & CEPH_OSD_OP_MODE_RD) && op != CEPH_OSD_OP_CALL; diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 58fbfe1..81733c0 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -559,7 +559,7 @@ EXPORT_SYMBOL(ceph_destroy_client); /* * true if we have the mon map (and have thus joined the cluster) */ -static int have_mon_and_osd_map(struct ceph_client *client) +static bool have_mon_and_osd_map(struct ceph_client *client) { return client->monc.monmap && client->monc.monmap->epoch && client->osdc.osdmap && client->osdc.osdmap->epoch;