]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ceph: code cleanup
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 11 Jun 2010 23:58:48 +0000 (16:58 -0700)
committerSage Weil <sage@newdream.net>
Mon, 2 Aug 2010 03:11:40 +0000 (20:11 -0700)
Mainly fixing minor issues reported by sparse.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
13 files changed:
fs/ceph/armor.c
fs/ceph/auth.c
fs/ceph/auth_x.c
fs/ceph/buffer.c
fs/ceph/caps.c
fs/ceph/crypto.c
fs/ceph/crypto.h
fs/ceph/decode.h
fs/ceph/dir.c
fs/ceph/file.c
fs/ceph/messenger.c
fs/ceph/osdmap.c
fs/ceph/xattr.c

index 67b2c030924b8bfd612c568d96a2ca0eb147b7a4..eb2a666b0be7011e9b27618c62060416543cb706 100644 (file)
@@ -1,11 +1,15 @@
 
 #include <linux/errno.h>
 
+int ceph_armor(char *dst, const char *src, const char *end);
+int ceph_unarmor(char *dst, const char *src, const char *end);
+
 /*
  * base64 encode/decode.
  */
 
-const char *pem_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char *pem_key =
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 static int encode_bits(int c)
 {
index 89490beaf5374a08bd933686fd6482c608d6d3a2..6d2e30600627e71d25c2f93d5862952a078472b8 100644 (file)
@@ -20,7 +20,7 @@ static u32 supported_protocols[] = {
        CEPH_AUTH_CEPHX
 };
 
-int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol)
+static int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol)
 {
        switch (protocol) {
        case CEPH_AUTH_NONE:
@@ -133,8 +133,8 @@ bad:
        return -ERANGE;
 }
 
-int ceph_build_auth_request(struct ceph_auth_client *ac,
-                          void *msg_buf, size_t msg_len)
+static int ceph_build_auth_request(struct ceph_auth_client *ac,
+                                  void *msg_buf, size_t msg_len)
 {
        struct ceph_mon_request_header *monhdr = msg_buf;
        void *p = monhdr + 1;
index 6d44053ecff1f08af7bee8546a0435ac55a0e1e2..582e0b2caf8a3ce6c2b943c0980c119be7950a63 100644 (file)
@@ -87,8 +87,8 @@ static int ceph_x_decrypt(struct ceph_crypto_key *secret,
 /*
  * get existing (or insert new) ticket handler
  */
-struct ceph_x_ticket_handler *get_ticket_handler(struct ceph_auth_client *ac,
-                                                int service)
+static struct ceph_x_ticket_handler *
+get_ticket_handler(struct ceph_auth_client *ac, int service)
 {
        struct ceph_x_ticket_handler *th;
        struct ceph_x_info *xi = ac->private;
@@ -429,7 +429,7 @@ static int ceph_x_build_request(struct ceph_auth_client *ac,
                auth->struct_v = 1;
                auth->key = 0;
                for (u = (u64 *)tmp_enc; u + 1 <= (u64 *)(tmp_enc + ret); u++)
-                       auth->key ^= *u;
+                       auth->key ^= *(__le64 *)u;
                dout(" server_challenge %llx client_challenge %llx key %llx\n",
                     xi->server_challenge, le64_to_cpu(auth->client_challenge),
                     le64_to_cpu(auth->key));
index c67535d70aa68a5ab3869f9dce4cc8bbe448e3e0..cd39f17021de9ab6cde35ce444a727970f4f8fab 100644 (file)
@@ -47,22 +47,6 @@ void ceph_buffer_release(struct kref *kref)
        kfree(b);
 }
 
-int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
-{
-       b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN);
-       if (b->vec.iov_base) {
-               b->is_vmalloc = false;
-       } else {
-               b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL);
-               b->is_vmalloc = true;
-       }
-       if (!b->vec.iov_base)
-               return -ENOMEM;
-       b->alloc_len = len;
-       b->vec.iov_len = len;
-       return 0;
-}
-
 int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end)
 {
        size_t len;
index dbf0d6a02a772d4e55be3cf64cda441aa0d1d4c8..d992880d21d4264288ac411c7ff38e14e322950a 100644 (file)
@@ -1194,6 +1194,8 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
  */
 void __ceph_flush_snaps(struct ceph_inode_info *ci,
                        struct ceph_mds_session **psession)
+               __releases(ci->vfs_inode->i_lock)
+               __acquires(ci->vfs_inode->i_lock)
 {
        struct inode *inode = &ci->vfs_inode;
        int mds;
@@ -1439,7 +1441,6 @@ static int try_nonblocking_invalidate(struct inode *inode)
  */
 void ceph_check_caps(struct ceph_inode_info *ci, int flags,
                     struct ceph_mds_session *session)
-       __releases(session->s_mutex)
 {
        struct ceph_client *client = ceph_inode_to_client(&ci->vfs_inode);
        struct ceph_mds_client *mdsc = &client->mdsc;
@@ -2256,8 +2257,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
                             struct ceph_mds_session *session,
                             struct ceph_cap *cap,
                             struct ceph_buffer *xattr_buf)
-       __releases(inode->i_lock)
-       __releases(session->s_mutex)
+               __releases(inode->i_lock)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
        int mds = session->s_mds;
index f704b3b624245b7cb44efa80f8949f3e9d9715f7..c9318278f419c7162bd648e7bd9706a4cc01907f 100644 (file)
@@ -75,10 +75,11 @@ static struct crypto_blkcipher *ceph_crypto_alloc_cipher(void)
        return crypto_alloc_blkcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC);
 }
 
-const u8 *aes_iv = "cephsageyudagreg";
+static const u8 *aes_iv = "cephsageyudagreg";
 
-int ceph_aes_encrypt(const void *key, int key_len, void *dst, size_t *dst_len,
-                    const void *src, size_t src_len)
+static int ceph_aes_encrypt(const void *key, int key_len,
+                           void *dst, size_t *dst_len,
+                           const void *src, size_t src_len)
 {
        struct scatterlist sg_in[2], sg_out[1];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
@@ -126,9 +127,10 @@ int ceph_aes_encrypt(const void *key, int key_len, void *dst, size_t *dst_len,
        return 0;
 }
 
-int ceph_aes_encrypt2(const void *key, int key_len, void *dst, size_t *dst_len,
-                     const void *src1, size_t src1_len,
-                     const void *src2, size_t src2_len)
+static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
+                            size_t *dst_len,
+                            const void *src1, size_t src1_len,
+                            const void *src2, size_t src2_len)
 {
        struct scatterlist sg_in[3], sg_out[1];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
@@ -179,8 +181,9 @@ int ceph_aes_encrypt2(const void *key, int key_len, void *dst, size_t *dst_len,
        return 0;
 }
 
-int ceph_aes_decrypt(const void *key, int key_len, void *dst, size_t *dst_len,
-                    const void *src, size_t src_len)
+static int ceph_aes_decrypt(const void *key, int key_len,
+                           void *dst, size_t *dst_len,
+                           const void *src, size_t src_len)
 {
        struct scatterlist sg_in[1], sg_out[2];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
@@ -238,10 +241,10 @@ int ceph_aes_decrypt(const void *key, int key_len, void *dst, size_t *dst_len,
        return 0;
 }
 
-int ceph_aes_decrypt2(const void *key, int key_len,
-                     void *dst1, size_t *dst1_len,
-                     void *dst2, size_t *dst2_len,
-                     const void *src, size_t src_len)
+static int ceph_aes_decrypt2(const void *key, int key_len,
+                            void *dst1, size_t *dst1_len,
+                            void *dst2, size_t *dst2_len,
+                            const void *src, size_t src_len)
 {
        struct scatterlist sg_in[1], sg_out[3];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
index 40b502e6bd89ca16a9e1efe084e7cfec6c4719f1..bdf38607323c2da2eb87d2c3ebf7b3d158bd7d0d 100644 (file)
@@ -42,7 +42,7 @@ extern int ceph_encrypt2(struct ceph_crypto_key *secret,
                         const void *src2, size_t src2_len);
 
 /* armor.c */
-extern int ceph_armor(char *dst, const void *src, const void *end);
-extern int ceph_unarmor(void *dst, const char *src, const char *end);
+extern int ceph_armor(char *dst, const char *src, const char *end);
+extern int ceph_unarmor(char *dst, const char *src, const char *end);
 
 #endif
index 65b3e022eaf5818d6514b770603d0f6552e2b6e6..3d25415afe6368debff12c405463e52c7683edc6 100644 (file)
@@ -99,11 +99,13 @@ static inline void ceph_encode_timespec(struct ceph_timespec *tv,
  */
 static inline void ceph_encode_addr(struct ceph_entity_addr *a)
 {
-       a->in_addr.ss_family = htons(a->in_addr.ss_family);
+       __be16 ss_family = htons(a->in_addr.ss_family);
+       a->in_addr.ss_family = *(__u16 *)&ss_family;
 }
 static inline void ceph_decode_addr(struct ceph_entity_addr *a)
 {
-       a->in_addr.ss_family = ntohs(a->in_addr.ss_family);
+       __be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
+       a->in_addr.ss_family = ntohs(ss_family);
        WARN_ON(a->in_addr.ss_family == 512);
 }
 
index f94ed3c7f6a5a862a3276b4b222231ab4c40e97f..0ec6e67533ef25297771b46cab99eecdc5029ba7 100644 (file)
@@ -94,6 +94,8 @@ static unsigned fpos_off(loff_t p)
  */
 static int __dcache_readdir(struct file *filp,
                            void *dirent, filldir_t filldir)
+               __releases(inode->i_lock)
+               __acquires(inode->i_lock)
 {
        struct inode *inode = filp->f_dentry->d_inode;
        struct ceph_file_info *fi = filp->private_data;
index 2329244f427b83b819453a3ca0be7018fcd5a72d..5fe50ffa2deb2622a1f4da7edf740dd11727e3b2 100644 (file)
@@ -317,7 +317,7 @@ void ceph_release_page_vector(struct page **pages, int num_pages)
 /*
  * allocate a vector new pages
  */
-struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
+static struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
 {
        struct page **pages;
        int i;
@@ -745,7 +745,7 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
        size_t len = iov->iov_len;
        struct inode *inode = filp->f_dentry->d_inode;
        struct ceph_inode_info *ci = ceph_inode(inode);
-       void *base = iov->iov_base;
+       void __user *base = iov->iov_base;
        ssize_t ret;
        int want, got = 0;
        int checkeof = 0, read = 0;
index 15167b2daa5562c3a093ba03fa14932657718551..71263a2a78d71c06ca1c647327c42d8e8b4aa9f5 100644 (file)
@@ -108,7 +108,7 @@ void ceph_msgr_exit(void)
        destroy_workqueue(ceph_msgr_wq);
 }
 
-void ceph_msgr_flush()
+void ceph_msgr_flush(void)
 {
        flush_workqueue(ceph_msgr_wq);
 }
@@ -1081,11 +1081,11 @@ static int process_banner(struct ceph_connection *con)
                   sizeof(con->peer_addr)) != 0 &&
            !(addr_is_blank(&con->actual_peer_addr.in_addr) &&
              con->actual_peer_addr.nonce == con->peer_addr.nonce)) {
-               pr_warning("wrong peer, want %s/%lld, got %s/%lld\n",
+               pr_warning("wrong peer, want %s/%d, got %s/%d\n",
                           pr_addr(&con->peer_addr.in_addr),
-                          le64_to_cpu(con->peer_addr.nonce),
+                          (int)le32_to_cpu(con->peer_addr.nonce),
                           pr_addr(&con->actual_peer_addr.in_addr),
-                          le64_to_cpu(con->actual_peer_addr.nonce));
+                          (int)le32_to_cpu(con->actual_peer_addr.nonce));
                con->error_msg = "wrong peer at address";
                return -1;
        }
index 416d46adbf87208544a1813ddfdadbabf4beb511..46b391d8e86c02b91dd7be4a421730df6dbbd11f 100644 (file)
@@ -424,7 +424,7 @@ static void __remove_pg_pool(struct rb_root *root, struct ceph_pg_pool_info *pi)
        kfree(pi);
 }
 
-void __decode_pool(void **p, struct ceph_pg_pool_info *pi)
+static void __decode_pool(void **p, struct ceph_pg_pool_info *pi)
 {
        ceph_decode_copy(p, &pi->v, sizeof(pi->v));
        calc_pg_masks(pi);
index 68aeebc696817ad537f7cac9997b093b5287a5cd..097a2654c00f517c004ef429b3c0046664f205c3 100644 (file)
@@ -337,6 +337,8 @@ void __ceph_destroy_xattrs(struct ceph_inode_info *ci)
 }
 
 static int __build_xattrs(struct inode *inode)
+       __releases(inode->i_lock)
+       __acquires(inode->i_lock)
 {
        u32 namelen;
        u32 numattr = 0;