From 86f225b52e5a2ee8c0d067292dfd4eadd7dbe70d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Sep 2009 11:32:03 -0700 Subject: [PATCH] kclient: audit inline --- src/kernel/caps.c | 29 ++++++++++++++++++++++++++ src/kernel/dir.c | 36 ++++++++++++++++++++++++++++++++ src/kernel/inode.c | 26 ----------------------- src/kernel/messenger.c | 11 ++++++++++ src/kernel/messenger.h | 12 +---------- src/kernel/super.h | 47 +++--------------------------------------- 6 files changed, 80 insertions(+), 81 deletions(-) diff --git a/src/kernel/caps.c b/src/kernel/caps.c index edf36cdfac483..f5af1a4098ac9 100644 --- a/src/kernel/caps.c +++ b/src/kernel/caps.c @@ -791,6 +791,35 @@ int ceph_caps_revoking(struct ceph_inode_info *ci, int mask) return ret; } +int __ceph_caps_used(struct ceph_inode_info *ci) +{ + int used = 0; + if (ci->i_pin_ref) + used |= CEPH_CAP_PIN; + if (ci->i_rd_ref) + used |= CEPH_CAP_FILE_RD; + if (ci->i_rdcache_ref || ci->i_rdcache_gen) + used |= CEPH_CAP_FILE_CACHE; + if (ci->i_wr_ref) + used |= CEPH_CAP_FILE_WR; + if (ci->i_wrbuffer_ref) + used |= CEPH_CAP_FILE_BUFFER; + return used; +} + +/* + * wanted, by virtue of open file modes + */ +int __ceph_caps_file_wanted(struct ceph_inode_info *ci) +{ + int want = 0; + int mode; + for (mode = 0; mode < 4; mode++) + if (ci->i_nr_by_mode[mode]) + want |= ceph_caps_for_mode(mode); + return want; +} + /* * Return caps we have registered with the MDS(s) as 'wanted'. */ diff --git a/src/kernel/dir.c b/src/kernel/dir.c index 5307263f6190b..7bb8db524e587 100644 --- a/src/kernel/dir.c +++ b/src/kernel/dir.c @@ -28,6 +28,42 @@ const struct inode_operations ceph_dir_iops; const struct file_operations ceph_dir_fops; struct dentry_operations ceph_dentry_ops; +/* + * Initialize ceph dentry state. + */ +int ceph_init_dentry(struct dentry *dentry) +{ + struct ceph_dentry_info *di; + + if (dentry->d_fsdata) + return 0; + + if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP) + dentry->d_op = &ceph_dentry_ops; + else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR) + dentry->d_op = &ceph_snapdir_dentry_ops; + else + dentry->d_op = &ceph_snap_dentry_ops; + + di = kmem_cache_alloc(ceph_dentry_cachep, GFP_NOFS); + if (!di) + return -ENOMEM; /* oh well */ + + spin_lock(&dentry->d_lock); + if (dentry->d_fsdata) /* lost a race */ + goto out_unlock; + di->dentry = dentry; + di->lease_session = NULL; + dentry->d_fsdata = di; + dentry->d_time = jiffies; + ceph_dentry_lru_add(dentry); +out_unlock: + spin_unlock(&dentry->d_lock); + return 0; +} + + + /* * for readdir, we encode the directory frag and offset within that * frag into f_pos. diff --git a/src/kernel/inode.c b/src/kernel/inode.c index c7402f0f9747c..aa5763d639dbf 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -721,32 +721,6 @@ out: return err; } -/* - * Initialize ceph dentry state. - */ -int ceph_init_dentry_private(struct dentry *dentry) -{ - struct ceph_dentry_info *di; - - if (dentry->d_fsdata) - return 0; - di = kmem_cache_alloc(ceph_dentry_cachep, GFP_NOFS); - if (!di) - return -ENOMEM; /* oh well */ - - spin_lock(&dentry->d_lock); - if (dentry->d_fsdata) /* lost a race */ - goto out_unlock; - di->dentry = dentry; - di->lease_session = NULL; - dentry->d_fsdata = di; - dentry->d_time = jiffies; - ceph_dentry_lru_add(dentry); -out_unlock: - spin_unlock(&dentry->d_lock); - return 0; -} - /* * caller should hold session s_mutex. */ diff --git a/src/kernel/messenger.c b/src/kernel/messenger.c index 77cf30000f13b..52e75b88ca073 100644 --- a/src/kernel/messenger.c +++ b/src/kernel/messenger.c @@ -31,6 +31,17 @@ static void queue_con(struct ceph_connection *con); static void con_work(struct work_struct *); static void ceph_fault(struct ceph_connection *con); +const char *ceph_name_type_str(int t) +{ + switch (t) { + case CEPH_ENTITY_TYPE_MON: return "mon"; + case CEPH_ENTITY_TYPE_MDS: return "mds"; + case CEPH_ENTITY_TYPE_OSD: return "osd"; + case CEPH_ENTITY_TYPE_CLIENT: return "client"; + case CEPH_ENTITY_TYPE_ADMIN: return "admin"; + default: return "???"; + } +} /* * work queue for all reading and writing to/from the socket. diff --git a/src/kernel/messenger.h b/src/kernel/messenger.h index 55cd4376f3016..f853908b2d2a8 100644 --- a/src/kernel/messenger.h +++ b/src/kernel/messenger.h @@ -54,17 +54,7 @@ struct ceph_connection_operations { int want); }; -static inline const char *ceph_name_type_str(int t) -{ - switch (t) { - case CEPH_ENTITY_TYPE_MON: return "mon"; - case CEPH_ENTITY_TYPE_MDS: return "mds"; - case CEPH_ENTITY_TYPE_OSD: return "osd"; - case CEPH_ENTITY_TYPE_CLIENT: return "client"; - case CEPH_ENTITY_TYPE_ADMIN: return "admin"; - default: return "???"; - } -} +extern const char *ceph_name_type_str(int t); /* use format string %s%d */ #define ENTITY_NAME(n) ceph_name_type_str((n).type), le64_to_cpu((n).num) diff --git a/src/kernel/super.h b/src/kernel/super.h index 669a9a4748fe6..7fa9f0b823947 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -528,35 +528,9 @@ static inline int __ceph_caps_dirty(struct ceph_inode_info *ci) extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask); extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask); +extern int __ceph_caps_used(struct ceph_inode_info *ci); -static inline int __ceph_caps_used(struct ceph_inode_info *ci) -{ - int used = 0; - if (ci->i_pin_ref) - used |= CEPH_CAP_PIN; - if (ci->i_rd_ref) - used |= CEPH_CAP_FILE_RD; - if (ci->i_rdcache_ref || ci->i_rdcache_gen) - used |= CEPH_CAP_FILE_CACHE; - if (ci->i_wr_ref) - used |= CEPH_CAP_FILE_WR; - if (ci->i_wrbuffer_ref) - used |= CEPH_CAP_FILE_BUFFER; - return used; -} - -/* - * wanted, by virtue of open file modes - */ -static inline int __ceph_caps_file_wanted(struct ceph_inode_info *ci) -{ - int want = 0; - int mode; - for (mode = 0; mode < 4; mode++) - if (ci->i_nr_by_mode[mode]) - want |= ceph_caps_for_mode(mode); - return want; -} +extern int __ceph_caps_file_wanted(struct ceph_inode_info *ci); /* * wanted, by virtue of open file modes AND cap refs (buffered/cached data) @@ -892,23 +866,8 @@ extern void ceph_dentry_lru_del(struct dentry *dn); * our d_ops vary depending on whether the inode is live, * snapshotted (read-only), or a virtual ".snap" directory. */ -int ceph_init_dentry_private(struct dentry *dentry); - -static inline int ceph_init_dentry(struct dentry *dentry) -{ - int ret; +int ceph_init_dentry(struct dentry *dentry); - if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP) - dentry->d_op = &ceph_dentry_ops; - else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR) - dentry->d_op = &ceph_snapdir_dentry_ops; - else - dentry->d_op = &ceph_snap_dentry_ops; - - ret = ceph_init_dentry_private(dentry); - - return ret; -} /* ioctl.c */ extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -- 2.39.5