From 93d92193080d6751d0d4b1d164cf26a3230be8da Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 17 Apr 2008 15:52:25 -0700 Subject: [PATCH] style fixups... no more complaints from checkpatch.pl --- src/include/ceph_fs.h | 42 +++---- src/kernel/addr.c | 58 +++++----- src/kernel/client.c | 52 ++++----- src/kernel/decode.h | 16 +-- src/kernel/dir.c | 10 +- src/kernel/file.c | 48 ++++---- src/kernel/inode.c | 244 ++++++++++++++++++++-------------------- src/kernel/ktcp.c | 233 +++++++++++++++++++------------------- src/kernel/mds_client.c | 38 +++---- src/kernel/mds_client.h | 16 +-- src/kernel/mdsmap.c | 29 ++--- src/kernel/messenger.c | 149 +++++++++++++----------- src/kernel/mon_client.c | 60 +++++----- src/kernel/osd_client.c | 119 ++++++++++---------- src/kernel/osd_client.h | 45 ++++---- src/kernel/osdmap.c | 120 ++++++++++---------- src/kernel/osdmap.h | 12 +- src/kernel/proc.c | 8 +- src/kernel/super.c | 27 ++--- src/kernel/super.h | 21 ++-- 20 files changed, 685 insertions(+), 662 deletions(-) diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 20449d1a89959..48aa79db11560 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -43,7 +43,7 @@ struct ceph_fsid { }; static inline int ceph_fsid_equal(const struct ceph_fsid *a, const struct ceph_fsid *b) { - return le64_to_cpu(a->major) == le64_to_cpu(b->major) && + return le64_to_cpu(a->major) == le64_to_cpu(b->major) && le64_to_cpu(a->minor) == le64_to_cpu(b->minor); } @@ -68,7 +68,7 @@ struct ceph_timespec { /* * dir fragments - */ + */ typedef __le32 ceph_frag_t; static inline __u32 frag_make(__u32 b, __u32 v) { return (b << 24) | (v & (0xffffffu >> (24-b))); } @@ -87,7 +87,7 @@ static inline __u32 frag_next(__u32 f) { return frag_make(frag_bits(f), frag_val /* * pg layout -- how PGs are mapped into (sets of) OSDs */ -#define CEPH_PG_LAYOUT_CRUSH 0 +#define CEPH_PG_LAYOUT_CRUSH 0 #define CEPH_PG_LAYOUT_HASH 1 #define CEPH_PG_LAYOUT_LINEAR 2 #define CEPH_PG_LAYOUT_HYBRID 3 @@ -101,7 +101,7 @@ struct ceph_file_layout { __u32 fl_stripe_count; /* over this many objects */ __u32 fl_object_size; /* until objects are this big, then move to new objects */ __u32 fl_cas_hash; /* 0 = none; 1 = sha256 */ - + /* pg -> disk layout */ __u32 fl_object_stripe_unit; /* for per-object parity, if any */ @@ -144,7 +144,7 @@ union ceph_pg { * e.g., b=12 -> bmask=15, b=123 -> bmask=127 */ static inline int ceph_stable_mod(int x, int b, int bmask) { - if ((x & bmask) < b) + if ((x & bmask) < b) return x & bmask; else return (x & (bmask>>1)); @@ -300,7 +300,7 @@ struct ceph_mds_getmap { /* - * mds states + * mds states * > 0 -> in * <= 0 -> out */ @@ -369,7 +369,7 @@ enum { CEPH_SESSION_RENEWCAPS, CEPH_SESSION_STALE, // caps not renewed. CEPH_SESSION_REQUEST_RESUME, - CEPH_SESSION_RESUME + CEPH_SESSION_RESUME }; struct ceph_mds_session_head { @@ -413,7 +413,7 @@ struct ceph_mds_request_head { __u32 op; __u32 caller_uid, caller_gid; - union { + union { struct { __u32 mask; } stat; @@ -431,7 +431,7 @@ struct ceph_mds_request_head { } __attribute__ ((packed)) utime; struct { __u32 mode; - } chmod; + } chmod; struct { __s32 uid; __s32 gid; @@ -439,10 +439,10 @@ struct ceph_mds_request_head { struct { __u32 mode; __u32 rdev; - } mknod; + } mknod; struct { __u32 mode; - } mkdir; + } mkdir; struct { __u32 flags; __u32 mode; @@ -509,16 +509,16 @@ static inline int ceph_flags_to_mode(int flags) if ((flags & O_DIRECTORY) == O_DIRECTORY) return CEPH_FILE_MODE_PIN; #ifdef O_LAZY - if (flags & O_LAZY) + if (flags & O_LAZY) return CEPH_FILE_MODE_LAZY; #endif - if ((flags & O_APPEND) == O_APPEND) + if ((flags & O_APPEND) == O_APPEND) flags |= O_WRONLY; - + flags &= O_ACCMODE; - if ((flags & O_RDWR) == O_RDWR) + if ((flags & O_RDWR) == O_RDWR) return CEPH_FILE_MODE_RDWR; - if ((flags & O_WRONLY) == O_WRONLY) + if ((flags & O_WRONLY) == O_WRONLY) return CEPH_FILE_MODE_WR; return CEPH_FILE_MODE_RD; } @@ -536,18 +536,18 @@ static inline int ceph_flags_to_mode(int flags) static inline int ceph_caps_for_mode(int mode) { switch (mode) { - case CEPH_FILE_MODE_PIN: + case CEPH_FILE_MODE_PIN: return CEPH_CAP_PIN; - case CEPH_FILE_MODE_RD: - return CEPH_CAP_PIN | + case CEPH_FILE_MODE_RD: + return CEPH_CAP_PIN | CEPH_CAP_RD | CEPH_CAP_RDCACHE; case CEPH_FILE_MODE_RDWR: - return CEPH_CAP_PIN | + return CEPH_CAP_PIN | CEPH_CAP_RD | CEPH_CAP_RDCACHE | CEPH_CAP_WR | CEPH_CAP_WRBUFFER | CEPH_CAP_EXCL; case CEPH_FILE_MODE_WR: - return CEPH_CAP_PIN | + return CEPH_CAP_PIN | CEPH_CAP_WR | CEPH_CAP_WRBUFFER | CEPH_CAP_EXCL; } diff --git a/src/kernel/addr.c b/src/kernel/addr.c index c8cfa6ef988bf..73a22bc1044e3 100644 --- a/src/kernel/addr.c +++ b/src/kernel/addr.c @@ -65,7 +65,7 @@ static int ceph_readpages(struct file *file, struct address_space *mapping, page_list, nr_pages); if (rc < 0) return rc; - + /* set uptodate and add to lru in pagevec-sized chunks */ pagevec_init(&pvec, 0); if (rc > 0) @@ -110,7 +110,7 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc) loff_t i_size; int err = 0; int was_dirty; - + if (!page->mapping || !page->mapping->host) return -EFAULT; inode = page->mapping->host; @@ -124,7 +124,7 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc) dout(10, "ceph_writepage inode %p page %p index %lu on %llu~%u\n", inode, page, page->index, page_off, len); - + page_cache_get(page); was_dirty = PageDirty(page); set_page_writeback(page); @@ -166,7 +166,7 @@ void ceph_release_pages(struct page **pages, int num) * ceph_writepages: * do write jobs for several pages */ -static int ceph_writepages(struct address_space *mapping, +static int ceph_writepages(struct address_space *mapping, struct writeback_control *wbc) { struct inode *inode = mapping->host; @@ -190,12 +190,12 @@ static int ceph_writepages(struct address_space *mapping, /* if wsize is small, write 1 page at a time */ if (wsize < PAGE_CACHE_SIZE) return generic_writepages(mapping, wbc); - + /* larger page vector? */ max_pages = wsize >> PAGE_CACHE_SHIFT; if (max_pages > PAGEVEC_SIZE) { pages = kmalloc(max_pages * sizeof(*pages), GFP_KERNEL); - if (!pages) + if (!pages) return generic_writepages(mapping, wbc); } else pages = 0; @@ -222,7 +222,7 @@ static int ceph_writepages(struct address_space *mapping, should_loop = 0; dout(10, "not cyclic, %lu to %lu\n", index, end); } - + retry: while (!done && index <= end) { @@ -236,9 +236,9 @@ retry: next = 0; locked_pages = 0; - get_more_pages: +get_more_pages: want = min(end - index, - min((pgoff_t)PAGEVEC_SIZE, + min((pgoff_t)PAGEVEC_SIZE, max_pages - (pgoff_t)locked_pages) - 1) + 1; pvec_pages = pagevec_lookup_tag(&pvec, mapping, &index, PAGECACHE_TAG_DIRTY, @@ -246,7 +246,7 @@ retry: for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) { page = pvec.pages[i]; - if (locked_pages == 0) + if (locked_pages == 0) lock_page(page); else if (TestSetPageLocked(page)) break; @@ -284,7 +284,7 @@ retry: end_page_writeback(page); break; } - + dout(50, "writepages locked page %p index %lu\n", page, page->index); @@ -312,7 +312,7 @@ retry: /* shift unused pages over in the pvec... we * will need to release them below. */ for (j = i; j < pvec_pages; j++) { - dout(50, " pvec leftover page %p\n", + dout(50, " pvec leftover page %p\n", pvec.pages[j]); pvec.pages[j-i] = pvec.pages[j]; } @@ -327,20 +327,20 @@ retry: unsigned wrote; dout(10, "writepages got %d pages at %llu~%llu\n", locked_pages, offset, len); - rc = ceph_osdc_writepages(&client->osdc, - ceph_ino(inode), + rc = ceph_osdc_writepages(&client->osdc, + ceph_ino(inode), &ci->i_layout, offset, len, pagep, locked_pages); if (rc >= 0) - wrote = (rc + (offset & ~PAGE_CACHE_MASK) - + ~PAGE_CACHE_MASK) + wrote = (rc + (offset & ~PAGE_CACHE_MASK) + + ~PAGE_CACHE_MASK) >> PAGE_CACHE_SHIFT; - else - wrote = 0; + else + wrote = 0; dout(20, "writepages rc %d wrote %d\n", rc, wrote); - + /* unmap+unlock pages */ for (i = 0; i < locked_pages; i++) { page = pagep[i]; @@ -352,7 +352,7 @@ retry: dout(50, "unlocking %d %p\n", i, page); unlock_page(page); end_page_writeback(page); - } + } ceph_put_wrbuffer_cap_refs(ci, wrote); /* continue? */ @@ -361,7 +361,7 @@ retry: if (wbc->nr_to_write <= 0) done = 1; } - + if (pages) { /* hmm, pagevec_release also does lru_add_drain()...? */ dout(50, "release_pages on %d\n", locked_pages); @@ -370,7 +370,7 @@ retry: dout(50, "pagevec_release on %d pages\n", (int)pvec.nr); pagevec_release(&pvec); } - + if (should_loop && !done) { /* more to do; loop back to beginning of file */ dout(40, "writepages looping back to beginning of file\n"); @@ -382,7 +382,7 @@ retry: mapping->writeback_index = index; kfree(pages); - if (rc > 0) + if (rc > 0) rc = 0; /* vfs expects us to return 0 */ dout(10, "writepages done, rc = %d\n", rc); return rc; @@ -407,7 +407,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping, /* get a page*/ page = __grab_cache_page(mapping, index); - if (!page) + if (!page) return -ENOMEM; *pagep = page; @@ -420,15 +420,15 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping, /* full page? */ if (pos_in_page == 0 && len == PAGE_SIZE) return 0; - + /* past end of file? */ i_size = inode->i_size; /* caller holds i_mutex */ - if (page_off >= i_size || + if (page_off >= i_size || (pos_in_page == 0 && (pos+len) >= i_size)) { simple_prepare_write(file, page, pos_in_page, pos_in_page+len); return 0; } - + /* we need to read it. */ /* or, do sub-page granularity dirty accounting? */ /* try to read the full page */ @@ -468,10 +468,10 @@ static int ceph_write_end(struct file *file, struct address_space *mapping, flush_dcache_page(page); kunmap_atomic(kaddr, KM_USER0); } - + /* did file size increase? */ /* (no need for i_size_read(); we caller holds i_mutex */ - if (pos+copied > inode->i_size) + if (pos+copied > inode->i_size) ceph_inode_set_size(inode, pos+copied); if (!PageUptodate(page)) diff --git a/src/kernel/client.c b/src/kernel/client.c index 04ff00a4c555c..49dc5c0df0a29 100644 --- a/src/kernel/client.c +++ b/src/kernel/client.c @@ -20,10 +20,10 @@ void ceph_peer_reset(void *p, struct ceph_entity_name *peer_name); /* * share work queue between clients. */ -static spinlock_t ceph_client_spinlock = SPIN_LOCK_UNLOCKED; -static int ceph_num_clients = 0; +spinlock_t ceph_client_spinlock; +int ceph_num_clients = 0; -static void get_client_counter(void) +static void get_client_counter(void) { spin_lock(&ceph_client_spinlock); if (ceph_num_clients == 0) { @@ -34,7 +34,7 @@ static void get_client_counter(void) spin_unlock(&ceph_client_spinlock); } -static void put_client_counter(void) +static void put_client_counter(void) { spin_lock(&ceph_client_spinlock); ceph_num_clients--; @@ -45,7 +45,7 @@ static void put_client_counter(void) spin_unlock(&ceph_client_spinlock); } -static struct dentry *open_root_dentry(struct ceph_client *client, +static struct dentry *open_root_dentry(struct ceph_client *client, struct ceph_mount_args *args) { struct ceph_mds_client *mdsc = &client->mdsc; @@ -56,9 +56,9 @@ static struct dentry *open_root_dentry(struct ceph_client *client, /* open dir */ dout(30, "open_root_inode opening '%s'\n", args->path); - req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_OPEN, + req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_OPEN, 1, args->path, 0, 0); - if (IS_ERR(req)) + if (IS_ERR(req)) return ERR_PTR(PTR_ERR(req)); req->r_expects_cap = 1; reqhead = req->r_request->front.iov_base; @@ -78,7 +78,7 @@ static struct dentry *open_root_dentry(struct ceph_client *client, /* * mount: join the ceph cluster. */ -int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, +int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, struct vfsmount *mnt) { struct ceph_msg *mount_msg; @@ -95,29 +95,27 @@ int ceph_mount(struct ceph_client *client, struct ceph_mount_args *args, mount_msg = ceph_msg_new(CEPH_MSG_CLIENT_MOUNT, 0, 0, 0, 0); if (IS_ERR(mount_msg)) return PTR_ERR(mount_msg); - mount_msg->hdr.dst.name.type = + mount_msg->hdr.dst.name.type = cpu_to_le32(CEPH_ENTITY_TYPE_MON); mount_msg->hdr.dst.name.num = cpu_to_le32(which); mount_msg->hdr.dst.addr = args->mon_addr[which]; - + ceph_msg_send(client->msgr, mount_msg, 0); - dout(10, "mount from mon%d, %d attempts left\n", + dout(10, "mount from mon%d, %d attempts left\n", which, attempts); - + /* wait */ dout(10, "mount sent mount request, waiting for maps\n"); - //err = wait_for_completion_timeout(&client->mount_completion, - //6*HZ); err = wait_event_interruptible_timeout( client->mount_wq, ceph_have_all_maps(client), 6*HZ); dout(10, "mount wait got %d\n", err); if (err == -EINTR) - return err; + return err; if (ceph_have_all_maps(client)) break; /* success */ - dout(10, "mount still waiting for mount, attempts=%d\n", + dout(10, "mount still waiting for mount, attempts=%d\n", attempts); if (--attempts == 0) return -EIO; @@ -145,7 +143,7 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg) void *new; dout(2, "handle_monmap had epoch %d\n", client->monc.monmap->epoch); - new = ceph_monmap_decode(msg->front.iov_base, + new = ceph_monmap_decode(msg->front.iov_base, msg->front.iov_base + msg->front.iov_len); if (IS_ERR(new)) { err = PTR_ERR(new); @@ -168,7 +166,7 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg) void got_first_map(struct ceph_client *client, int num) { set_bit(num, &client->mounting); - dout(10, "got_first_map num %d mounting now %lu done=%d\n", + dout(10, "got_first_map num %d mounting now %lu done=%d\n", num, client->mounting, ceph_have_all_maps(client)); if (ceph_have_all_maps(client)) { dout(10, "got_first_map kicking mount\n"); @@ -181,7 +179,8 @@ void got_first_map(struct ceph_client *client, int num) /* * create a fresh client instance */ -struct ceph_client *ceph_create_client(struct ceph_mount_args *args, struct super_block *sb) +struct ceph_client *ceph_create_client(struct ceph_mount_args *args, + struct super_block *sb) { struct ceph_client *cl; struct ceph_entity_addr *myaddr = 0; @@ -212,9 +211,10 @@ struct ceph_client *ceph_create_client(struct ceph_mount_args *args, struct supe cl->msgr->dispatch = ceph_dispatch; cl->msgr->prepare_pages = ceph_osdc_prepare_pages; cl->msgr->peer_reset = ceph_peer_reset; - + cl->whoami = -1; - if ((err = ceph_monc_init(&cl->monc, cl)) < 0) + err = ceph_monc_init(&cl->monc, cl); + if (err < 0) goto fail; ceph_mdsc_init(&cl->mdsc, cl); ceph_osdc_init(&cl->osdc, cl); @@ -232,7 +232,7 @@ fail: void ceph_umount_start(struct ceph_client *cl) { - ceph_mdsc_stop(&cl->mdsc); + ceph_mdsc_stop(&cl->mdsc); } void ceph_destroy_client(struct ceph_client *cl) @@ -281,7 +281,7 @@ void ceph_dispatch(void *p, struct ceph_msg *msg) case CEPH_MSG_MDS_MAP: had = client->mdsc.mdsmap ? 1:0; ceph_mdsc_handle_map(&client->mdsc, msg); - if (!had && client->mdsc.mdsmap) + if (!had && client->mdsc.mdsmap) got_first_map(client, 1); break; case CEPH_MSG_CLIENT_SESSION: @@ -304,7 +304,7 @@ void ceph_dispatch(void *p, struct ceph_msg *msg) case CEPH_MSG_OSD_MAP: had = client->osdc.osdmap ? 1:0; ceph_osdc_handle_map(&client->osdc, msg); - if (!had && client->osdc.osdmap) + if (!had && client->osdc.osdmap) got_first_map(client, 2); break; case CEPH_MSG_OSD_OPREPLY: @@ -318,7 +318,7 @@ void ceph_dispatch(void *p, struct ceph_msg *msg) ceph_msg_put(msg); } -const char *ceph_msg_type_name(int type) +const char *ceph_msg_type_name(int type) { switch (type) { case CEPH_MSG_SHUTDOWN: return "shutdown"; @@ -349,7 +349,7 @@ const char *ceph_msg_type_name(int type) void ceph_peer_reset(void *p, struct ceph_entity_name *peer_name) { struct ceph_client *client = p; - + dout(30, "ceph_peer_reset peer_name = %s%d\n", ENTITY_NAME(*peer_name)); /* write me */ diff --git a/src/kernel/decode.h b/src/kernel/decode.h index 76bc57a2cdf6e..8a4f477de51e4 100644 --- a/src/kernel/decode.h +++ b/src/kernel/decode.h @@ -2,7 +2,7 @@ #define __CEPH_DECODE_H /* - * in all cases, + * in all cases, * void **p pointer to position pointer * void *end pointer to end of buffer (last byte + 1) */ @@ -67,7 +67,7 @@ /* * struct ceph_timespec <-> struct timespec - */ + */ #define ceph_decode_timespec(ts, tv) \ do { \ (ts)->tv_sec = le32_to_cpu((tv)->tv_sec); \ @@ -82,7 +82,7 @@ /* * encoders - */ + */ #define ceph_encode_64(p, v) \ do { \ @@ -105,23 +105,23 @@ (*(p))++; \ } while (0) -/* - * filepath, string encoders +/* + * filepath, string encoders */ -static __inline__ void ceph_encode_filepath(void **p, void *end, +static __inline__ void ceph_encode_filepath(void **p, void *end, ceph_ino_t ino, const char *path) { __u32 len = path ? strlen(path):0; BUG_ON(*p + sizeof(ino) + sizeof(len) + len > end); ceph_encode_64(p, ino); ceph_encode_32(p, len); - if (len) + if (len) memcpy(*p, path, len); *p += len; } -static __inline__ void ceph_encode_string(void **p, void *end, +static __inline__ void ceph_encode_string(void **p, void *end, const char *s, __u32 len) { BUG_ON(*p + sizeof(len) + len > end); diff --git a/src/kernel/dir.c b/src/kernel/dir.c index ed79d37b500a1..d3fcdb55b64a5 100644 --- a/src/kernel/dir.c +++ b/src/kernel/dir.c @@ -371,7 +371,7 @@ static int ceph_dir_link(struct dentry *old_dentry, struct inode *dir, int oldpathlen, pathlen; int err; - dout(5, "dir_link in dir %p old_dentry %p dentry %p\n", dir, + dout(5, "dir_link in dir %p old_dentry %p dentry %p\n", dir, old_dentry, dentry); oldpath = ceph_build_dentry_path(old_dentry, &oldpathlen); if (IS_ERR(oldpath)) @@ -409,7 +409,7 @@ static int ceph_dir_link(struct dentry *old_dentry, struct inode *dir, */ } else d_drop(dentry); - + return err; } @@ -436,7 +436,7 @@ static int ceph_dir_unlink(struct inode *dir, struct dentry *dentry) kfree(path); if (IS_ERR(req)) return PTR_ERR(req); - ceph_mdsc_lease_release(mdsc, dir, dentry, + ceph_mdsc_lease_release(mdsc, dir, dentry, CEPH_LOCK_DN|CEPH_LOCK_ICONTENT); ceph_mdsc_lease_release(mdsc, dentry->d_inode, 0, CEPH_LOCK_ILINK); err = ceph_mdsc_do_request(mdsc, req); @@ -482,10 +482,10 @@ static int ceph_dir_rename(struct inode *old_dir, struct dentry *old_dentry, req->r_old_dentry = old_dentry; dget(new_dentry); req->r_last_dentry = new_dentry; - ceph_mdsc_lease_release(mdsc, old_dir, old_dentry, + ceph_mdsc_lease_release(mdsc, old_dir, old_dentry, CEPH_LOCK_DN|CEPH_LOCK_ICONTENT); if (new_dentry->d_inode) - ceph_mdsc_lease_release(mdsc, new_dentry->d_inode, 0, + ceph_mdsc_lease_release(mdsc, new_dentry->d_inode, 0, CEPH_LOCK_ILINK); err = ceph_mdsc_do_request(mdsc, req); ceph_mdsc_put_request(req); diff --git a/src/kernel/file.c b/src/kernel/file.c index aab7cad8df7db..bcf23bb8b3a07 100644 --- a/src/kernel/file.c +++ b/src/kernel/file.c @@ -80,7 +80,7 @@ int ceph_open(struct inode *inode, struct file *file) int flags = file->f_flags & ~(O_CREAT|O_EXCL); if (S_ISDIR(inode->i_mode)) flags = O_DIRECTORY; - + fmode = ceph_flags_to_mode(flags); wantcaps = ceph_caps_for_mode(fmode); @@ -94,12 +94,12 @@ int ceph_open(struct inode *inode, struct file *file) /* can we re-use existing caps? */ spin_lock(&inode->i_lock); if ((__ceph_caps_issued(ci) & wantcaps) == wantcaps) { - dout(10, "open fmode %d caps %d using existing on %p\n", + dout(10, "open fmode %d caps %d using existing on %p\n", fmode, wantcaps, inode); __ceph_get_fmode(ci, fmode); spin_unlock(&inode->i_lock); return ceph_init_file(inode, file, fmode); - } + } spin_unlock(&inode->i_lock); dout(10, "open mode %d, don't have caps %d\n", fmode, wantcaps); @@ -134,7 +134,7 @@ int ceph_lookup_open(struct inode *dir, struct dentry *dentry, struct ceph_mds_request *req; int err; int flags = nd->intent.open.flags; - dout(5, "ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n", + dout(5, "ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n", dentry, dentry->d_name.len, dentry->d_name.name, flags, mode); /* do the open */ @@ -168,9 +168,11 @@ int ceph_release(struct inode *inode, struct file *file) * FIXME mystery: why is file->f_flags now different than * file->f_flags (actually, nd->intent.open.flags) on * open? e.g., on ceph_lookup_open, - * ceph_file: opened 000000006fa3ebd0 flags 0101102 mode 2 nr now 1. wanted 0 -> 30 + * ceph_file: opened 000000006fa3ebd0 flags 0101102 mode 2 nr now 1.\ + * wanted 0 -> 30 * and on release, - * ceph_file: released 000000006fa3ebd0 flags 0100001 mode 3 nr now -1. wanted 30 was 30 + * ceph_file: released 000000006fa3ebd0 flags 0100001 mode 3 nr now \ + * -1. wanted 30 was 30 * for now, store the open mode in ceph_file_info. */ @@ -206,7 +208,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data, dout(10, "sync_read on file %p %lld~%u\n", file, *offset, (unsigned)count); - + ret = ceph_osdc_sync_read(&client->osdc, ceph_ino(inode), &ci->i_layout, pos, count, data); @@ -236,13 +238,13 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, if (ret > 0) { pos += ret; *offset = pos; - if (pos > i_size_read(inode)) + if (pos > i_size_read(inode)) ceph_inode_set_size(inode, pos); } return ret; } -/* +/* * wrap do_sync_read and friends with checks for cap bits on the inode. * atomically grab references, so that those bits are not released mid-read. */ @@ -256,16 +258,16 @@ ssize_t ceph_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) dout(10, "read %llx %llu~%u trying to get caps\n", ceph_ino(inode), *ppos, (unsigned)len); ret = wait_event_interruptible(ci->i_cap_wq, - ceph_get_cap_refs(ci, CEPH_CAP_RD, - CEPH_CAP_RDCACHE, + ceph_get_cap_refs(ci, CEPH_CAP_RD, + CEPH_CAP_RDCACHE, &got, -1)); - if (ret < 0) + if (ret < 0) goto out; dout(10, "read %llx %llu~%u got cap refs %d\n", ceph_ino(inode), *ppos, (unsigned)len, got); if ((got & CEPH_CAP_RDCACHE) == 0 || - (inode->i_sb->s_flags & MS_SYNCHRONOUS)) + (inode->i_sb->s_flags & MS_SYNCHRONOUS)) ret = ceph_sync_read(filp, buf, len, ppos); else ret = do_sync_read(filp, buf, len, ppos); @@ -279,7 +281,7 @@ out: /* * ditto */ -ssize_t ceph_write(struct file *filp, const char __user *buf, +ssize_t ceph_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos) { struct inode *inode = filp->f_dentry->d_inode; @@ -290,37 +292,37 @@ ssize_t ceph_write(struct file *filp, const char __user *buf, /* do we need to explicitly request a larger max_size? */ spin_lock(&inode->i_lock); - if (*ppos > ci->i_max_size && + if (*ppos > ci->i_max_size && *ppos > (inode->i_size << 1) && *ppos > ci->i_wanted_max_size) { dout(10, "write %p at large offset %llu, requesting max_size\n", inode, *ppos); - ci->i_wanted_max_size = *ppos; + ci->i_wanted_max_size = *ppos; check = 1; } - spin_unlock(&inode->i_lock); + spin_unlock(&inode->i_lock); if (check) ceph_check_caps(ci, 1); - dout(10, "write %p %llu~%u getting caps. i_size %llu\n", + dout(10, "write %p %llu~%u getting caps. i_size %llu\n", inode, *ppos, (unsigned)len, inode->i_size); ret = wait_event_interruptible(ci->i_cap_wq, - ceph_get_cap_refs(ci, CEPH_CAP_WR, + ceph_get_cap_refs(ci, CEPH_CAP_WR, CEPH_CAP_WRBUFFER, &got, *ppos)); - if (ret < 0) + if (ret < 0) goto out; - dout(10, "write %p %llu~%u got cap refs on %d\n", + dout(10, "write %p %llu~%u got cap refs on %d\n", inode, *ppos, (unsigned)len, got); if ((got & CEPH_CAP_WRBUFFER) == 0 || - (inode->i_sb->s_flags & MS_SYNCHRONOUS)) + (inode->i_sb->s_flags & MS_SYNCHRONOUS)) ret = ceph_sync_write(filp, buf, len, ppos); else ret = do_sync_write(filp, buf, len, ppos); out: - dout(10, "write %p %llu~%u dropping cap refs on %d\n", + dout(10, "write %p %llu~%u dropping cap refs on %d\n", inode, *ppos, (unsigned)len, got); ceph_put_cap_refs(ci, got); return ret; diff --git a/src/kernel/inode.c b/src/kernel/inode.c index ed431d142ace1..5f61ddfe2ef9b 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -32,7 +32,7 @@ struct inode *ceph_get_inode(struct super_block *sb, __u64 ino) #else inode = iget5_locked(sb, inot, ceph_ino_compare, ceph_set_ino_cb, &ino); #endif - if (inode == NULL) + if (inode == NULL) return ERR_PTR(-ENOMEM); if (inode->i_state & I_NEW) { dout(40, "get_inode created new inode %p %llx\n", inode, @@ -54,7 +54,7 @@ struct inode *ceph_get_inode(struct super_block *sb, __u64 ino) * populate an inode based on info from mds. * may be called on new or existing inodes. */ -int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info) +int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info) { struct ceph_inode_info *ci = ceph_inode(inode); int i; @@ -67,21 +67,21 @@ int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info) struct timespec mtime, atime, ctime; u64 blocks = (size + blksize - 1) >> blkbits; - dout(30, "fill_inode %p ino %llx by %d.%d sz=%llu mode %o nlink %d\n", - inode, info->ino, inode->i_uid, inode->i_gid, + dout(30, "fill_inode %p ino %llx by %d.%d sz=%llu mode %o nlink %d\n", + inode, info->ino, inode->i_uid, inode->i_gid, inode->i_size, inode->i_mode, inode->i_nlink); dout(30, " su %d, blkbits %d, blksize %u, blocks %llu\n", - su, blkbits, blksize, blocks); + su, blkbits, blksize, blocks); ceph_set_ino(inode, le64_to_cpu(info->ino)); spin_lock(&inode->i_lock); - dout(30, " got version %llu, had %llu\n", + dout(30, " got version %llu, had %llu\n", le64_to_cpu(info->version), ci->i_version); if (le64_to_cpu(info->version) > 0 && ci->i_version == le64_to_cpu(info->version)) goto no_change; - ci->i_version = le64_to_cpu(info->version); + ci->i_version = le64_to_cpu(info->version); inode->i_mode = le32_to_cpu(info->mode); inode->i_uid = le32_to_cpu(info->uid); inode->i_gid = le32_to_cpu(info->gid); @@ -117,24 +117,23 @@ int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info) } /* ceph inode */ - ci->i_layout = info->layout; - if (ci->i_symlink) - kfree(ci->i_symlink); + ci->i_layout = info->layout; + kfree(ci->i_symlink); ci->i_symlink = 0; if (le32_to_cpu(info->fragtree.nsplits) > 0) { - //ci->i_fragtree = kmalloc(...); - BUG_ON(1); // write me + /*ci->i_fragtree = kmalloc(...); */ + BUG_ON(1); /* write me */ } ci->i_fragtree->nsplits = le32_to_cpu(info->fragtree.nsplits); - for (i=0; ii_fragtree->nsplits; i++) - ci->i_fragtree->splits[i] = + for (i = 0; i < ci->i_fragtree->nsplits; i++) + ci->i_fragtree->splits[i] = le32_to_cpu(info->fragtree.splits[i]); ci->i_frag_map_nr = 1; ci->i_frag_map[0].frag = 0; - ci->i_frag_map[0].mds = 0; // FIXME - + ci->i_frag_map[0].mds = 0; /* FIXME */ + ci->i_old_atime = inode->i_atime; ci->i_max_size = le64_to_cpu(info->max_size); @@ -166,14 +165,16 @@ no_change: case S_IFLNK: dout(20, "%p is a symlink\n", inode); inode->i_op = &ceph_symlink_iops; - symlen = le32_to_cpu(*(__u32*)(info->fragtree.splits+ci->i_fragtree->nsplits)); + symlen = le32_to_cpu(*(__u32 *)(info->fragtree.splits + + ci->i_fragtree->nsplits)); dout(20, "symlink len is %d\n", symlen); BUG_ON(symlen != ci->vfs_inode.i_size); ci->i_symlink = kmalloc(symlen+1, GFP_KERNEL); if (ci->i_symlink == NULL) return -ENOMEM; - memcpy(ci->i_symlink, - (char*)(info->fragtree.splits+ci->i_fragtree->nsplits) + 4, + memcpy(ci->i_symlink, + (char *)(info->fragtree.splits + + ci->i_fragtree->nsplits) + 4, symlen); ci->i_symlink[symlen] = 0; dout(20, "symlink is '%s'\n", ci->i_symlink); @@ -192,13 +193,13 @@ no_change: return 0; } -/* +/* * caller must hold session s_mutex. */ -void ceph_update_inode_lease(struct inode *inode, +void ceph_update_inode_lease(struct inode *inode, struct ceph_mds_reply_lease *lease, struct ceph_mds_session *session, - unsigned long from_time) + unsigned long from_time) { struct ceph_inode_info *ci = ceph_inode(inode); __u64 ttl = le32_to_cpu(lease->duration_ms) * HZ; @@ -226,7 +227,7 @@ void ceph_update_inode_lease(struct inode *inode, if (!ci->i_lease_session) { ci->i_lease_session = session; is_new = 1; - } + } list_move_tail(&ci->i_lease_item, &session->s_inode_leases); } spin_unlock(&inode->i_lock); @@ -244,7 +245,7 @@ int ceph_inode_lease_valid(struct inode *inode, int mask) struct ceph_inode_info *ci = ceph_inode(inode); int havemask; int valid = 0; - + spin_lock(&inode->i_lock); havemask = ci->i_lease_mask; /* EXCL cap counts for an ICONTENT lease */ @@ -253,7 +254,7 @@ int ceph_inode_lease_valid(struct inode *inode, int mask) havemask |= CEPH_LOCK_ICONTENT; } /* any ICONTENT bits imply all bits */ - if (havemask & CEPH_LOCK_ICONTENT) + if (havemask & CEPH_LOCK_ICONTENT) havemask |= CEPH_LOCK_ICONTENT; if ((havemask & mask) != mask) @@ -270,10 +271,10 @@ out: /* * caller should hold session s_mutex. */ -void ceph_update_dentry_lease(struct dentry *dentry, +void ceph_update_dentry_lease(struct dentry *dentry, struct ceph_mds_reply_lease *lease, struct ceph_mds_session *session, - unsigned long from_time) + unsigned long from_time) { __u64 ttl = le32_to_cpu(lease->duration_ms) * HZ; struct ceph_dentry_info *di; @@ -289,7 +290,7 @@ void ceph_update_dentry_lease(struct dentry *dentry, return; spin_lock(&dentry->d_lock); - if (ttl < dentry->d_time) + if (ttl < dentry->d_time) goto fail_unlock; /* older. */ di = ceph_dentry(dentry); @@ -300,8 +301,8 @@ void ceph_update_dentry_lease(struct dentry *dentry, if (!di) return; /* oh well */ spin_lock(&dentry->d_lock); - if (dentry->d_fsdata) { /* lost a race! */ - kfree(di); + if (dentry->d_fsdata) { + kfree(di); /* lost a race! */ goto fail_unlock; } di->dentry = dentry; @@ -324,7 +325,7 @@ void ceph_update_dentry_lease(struct dentry *dentry, return; fail_unlock: - spin_unlock(&dentry->d_lock); + spin_unlock(&dentry->d_lock); } /* @@ -336,7 +337,7 @@ int ceph_dentry_lease_valid(struct dentry *dentry) int valid = 0; spin_lock(&dentry->d_lock); di = ceph_dentry(dentry); - if (di && time_after(dentry->d_time, jiffies)) + if (di && time_after(dentry->d_time, jiffies)) valid = 1; spin_unlock(&dentry->d_lock); dout(20, "dentry_lease_valid - dentry %p = %d\n", dentry, valid); @@ -346,7 +347,7 @@ int ceph_dentry_lease_valid(struct dentry *dentry) -int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, +int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, struct ceph_mds_session *session) { struct ceph_mds_reply_info *rinfo = &req->r_reply_info; @@ -367,8 +368,9 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, in = dn->d_inode; } else { /* first reply (i.e. mount) */ - in = ceph_get_inode(sb,le64_to_cpu(rinfo->trace_in[0].in->ino)); - if (IS_ERR(in)) + in = ceph_get_inode(sb, + le64_to_cpu(rinfo->trace_in[0].in->ino)); + if (IS_ERR(in)) return PTR_ERR(in); dn = d_alloc_root(in); if (dn == NULL) { @@ -380,7 +382,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, err = ceph_fill_inode(in, rinfo->trace_in[0].in); if (err < 0) return err; - ceph_update_inode_lease(in, rinfo->trace_ilease[0], session, + ceph_update_inode_lease(in, rinfo->trace_ilease[0], session, req->r_from_time); if (sb->s_root == NULL) @@ -388,11 +390,11 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, dget(dn); for (d = 0; d < rinfo->trace_numd; d++) { - dout(10, "fill_trace dn %d/%d dn %p in %p\n", + dout(10, "fill_trace dn %d/%d dn %p in %p\n", (d+1), rinfo->trace_numd, dn, dn->d_inode); parent = dn; - + /* dentry */ ininfo = rinfo->trace_in[d+1].in; if (d == rinfo->trace_numd-1 && req->r_last_dentry) { @@ -412,9 +414,9 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, dname.name = rinfo->trace_dname[d]; dname.len = rinfo->trace_dname_len[d]; dname.hash = full_name_hash(dname.name, dname.len); - retry_lookup: +retry_lookup: dn = d_lookup(parent, &dname); - dout(10, "fill_trace d_lookup of '%.*s' got %p\n", + dout(10, "fill_trace d_lookup of '%.*s' got %p\n", (int)dname.len, dname.name, dn); if (d+1 < rinfo->trace_numi && dn && dn->d_inode && @@ -435,7 +437,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, } } if (dn->d_parent == parent) - ceph_update_dentry_lease(dn, rinfo->trace_dlease[d], + ceph_update_dentry_lease(dn, rinfo->trace_dlease[d], session, req->r_from_time); /* inode */ @@ -453,13 +455,13 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, if (!dn->d_inode) { dout(10, "fill_trace attaching inode\n"); - if (req->r_last_inode && ceph_ino(req->r_last_inode) == + if (req->r_last_inode && ceph_ino(req->r_last_inode) == le64_to_cpu(ininfo->ino)) { in = req->r_last_inode; igrab(in); inc_nlink(in); } else { - in = ceph_get_inode(dn->d_sb, + in = ceph_get_inode(dn->d_sb, le64_to_cpu(ininfo->ino)); if (IS_ERR(in)) { dout(30, "new_inode badness\n"); @@ -470,7 +472,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, break; } } - if ((err = ceph_fill_inode(in, ininfo)) < 0) { + err = ceph_fill_inode(in, ininfo); + if (err < 0) { dout(30, "ceph_fill_inode badness\n"); iput(in); d_delete(dn); @@ -485,7 +488,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, " inode %llx\n", dn, ceph_ino(in)); } else { in = dn->d_inode; - if ((err = ceph_fill_inode(in, ininfo)) < 0) { + err = ceph_fill_inode(in, ininfo); + if (err < 0) { dout(30, "ceph_fill_inode badness\n"); break; } @@ -523,7 +527,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req) struct inode *in; int i; - dout(10, "readdir_prepopulate %d items under dentry %p\n", + dout(10, "readdir_prepopulate %d items under dentry %p\n", rinfo->dir_nr, parent); for (i = 0; i < rinfo->dir_nr; i++) { /* dentry */ @@ -531,13 +535,13 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req) dname.len = rinfo->dir_dname_len[i]; dname.hash = full_name_hash(dname.name, dname.len); - retry_lookup: +retry_lookup: dn = d_lookup(parent, &dname); dout(30, "calling d_lookup on parent=%p name=%.*s" " returned %p\n", parent, dname.len, dname.name, dn); if (dn && dn->d_inode && - ceph_ino(dn->d_inode) != + ceph_ino(dn->d_inode) != le64_to_cpu(rinfo->dir_in[i].in->ino)) { dout(10, " dn %p points to wrong inode %p\n", dn, dn->d_inode); @@ -546,7 +550,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req) } if (!dn) { dn = d_alloc(parent, &dname); - dout(40, "d_alloc %p/%.*s\n", parent, + dout(40, "d_alloc %p/%.*s\n", parent, dname.len, dname.name); if (dn == NULL) { dout(30, "d_alloc badness\n"); @@ -556,10 +560,10 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req) } /* inode */ - if (dn->d_inode) + if (dn->d_inode) in = dn->d_inode; else { - in = ceph_get_inode(parent->d_sb, + in = ceph_get_inode(parent->d_sb, rinfo->dir_in[i].in->ino); if (in == NULL) { dout(30, "new_inode badness\n"); @@ -576,9 +580,9 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req) if (d_unhashed(dn)) d_rehash(dn); } - ceph_update_dentry_lease(dn, rinfo->dir_dlease[i], + ceph_update_dentry_lease(dn, rinfo->dir_dlease[i], req->r_session, req->r_from_time); - ceph_update_inode_lease(in, rinfo->dir_ilease[i], + ceph_update_inode_lease(in, rinfo->dir_ilease[i], req->r_session, req->r_from_time); dput(dn); } @@ -599,7 +603,7 @@ static struct ceph_inode_cap *__get_cap_for_mds(struct inode *inode, int mds) list_for_each(p, &ci->i_caps) { cap = list_entry(p, struct ceph_inode_cap, ci_caps); - if (cap->mds == mds) + if (cap->mds == mds) return cap; } return 0; @@ -609,7 +613,7 @@ static struct ceph_inode_cap *__get_cap_for_mds(struct inode *inode, int mds) * caller shoudl hold session s_mutex. */ struct ceph_inode_cap *ceph_add_cap(struct inode *inode, - struct ceph_mds_session *session, + struct ceph_mds_session *session, int fmode, u32 issued, u32 seq) { @@ -624,7 +628,7 @@ struct ceph_inode_cap *ceph_add_cap(struct inode *inode, spin_lock(&inode->i_lock); cap = __get_cap_for_mds(inode, mds); if (!cap) { - for (i=0; ii_static_caps[i].mds == -1) { cap = &ci->i_static_caps[i]; break; @@ -640,13 +644,13 @@ struct ceph_inode_cap *ceph_add_cap(struct inode *inode, spin_lock(&inode->i_lock); } } - + is_new = 1; /* grab inode later */ cap->issued = cap->implemented = 0; cap->mds = mds; cap->seq = 0; cap->flags = 0; - + cap->ci = ci; list_add(&cap->ci_caps, &ci->i_caps); @@ -698,9 +702,9 @@ void __ceph_remove_cap(struct ceph_inode_cap *cap) list_del_init(&cap->ci_caps); cap->session = 0; cap->mds = -1; /* mark unused */ - - if (cap < cap->ci->i_static_caps || - cap >= cap->ci->i_static_caps + STATIC_CAPS) + + if (cap < cap->ci->i_static_caps || + cap >= cap->ci->i_static_caps + STATIC_CAPS) kfree(cap); } @@ -719,13 +723,13 @@ void ceph_remove_cap(struct ceph_inode_cap *cap) void ceph_cap_delayed_work(struct work_struct *work) { - struct ceph_inode_info *ci = container_of(work, - struct ceph_inode_info, + struct ceph_inode_info *ci = container_of(work, + struct ceph_inode_info, i_cap_dwork.work); spin_lock(&ci->vfs_inode.i_lock); if (ci->i_hold_caps_until > jiffies) { dout(10, "cap_dwork on %p -- rescheduling\n", &ci->vfs_inode); - schedule_delayed_work(&ci->i_cap_dwork, + schedule_delayed_work(&ci->i_cap_dwork, ci->i_hold_caps_until - jiffies); spin_unlock(&ci->vfs_inode.i_lock); goto out; @@ -761,7 +765,7 @@ retry: spin_lock(&inode->i_lock); wanted = __ceph_caps_wanted(ci); used = __ceph_caps_used(ci); - dout(10, "check_caps %p wanted %d used %d issued %d\n", inode, + dout(10, "check_caps %p wanted %d used %d issued %d\n", inode, wanted, used, __ceph_caps_issued(ci)); if (was_last) { @@ -770,7 +774,7 @@ retry: ci->i_hold_caps_until = until; dout(10, "hold_caps_until %lu\n", until); cancel_delayed_work(&ci->i_cap_dwork); - schedule_delayed_work(&ci->i_cap_dwork, + schedule_delayed_work(&ci->i_cap_dwork, until - jiffies); } } @@ -800,17 +804,17 @@ retry: dout(10, "i_size approaching max_size\n"); goto ack; } - + if ((cap->issued & ~wanted) == 0) continue; /* nothing extra, all good */ - + if (jiffies < ci->i_hold_caps_until) { /* delaying cap release for a bit */ dout(30, "delaying cap release\n"); continue; } - ack: +ack: /* take s_mutex, one way or another */ if (session && session != cap->session) { dout(30, "oops, wrong session mutex\n"); @@ -831,9 +835,9 @@ retry: dropping = cap->issued & ~wanted; cap->issued &= wanted; /* drop bits we don't want */ - if (revoking && (revoking && used) == 0) + if (revoking && (revoking && used) == 0) cap->implemented = cap->issued; - + keep = cap->issued; seq = cap->seq; size = inode->i_size; @@ -853,8 +857,8 @@ retry: dout(20, "done invalidating pages on %p\n", inode); } - ceph_mdsc_send_cap_ack(mdsc, ceph_ino(inode), - keep, wanted, seq, + ceph_mdsc_send_cap_ack(mdsc, ceph_ino(inode), + keep, wanted, seq, size, max_size, &mtime, &atime, mds); if (wanted == 0) @@ -873,13 +877,13 @@ retry: void ceph_inode_set_size(struct inode *inode, loff_t size) { struct ceph_inode_info *ci = ceph_inode(inode); - + spin_lock(&inode->i_lock); dout(20, "set_size %p %llu -> %llu\n", inode, inode->i_size, size); inode->i_size = size; inode->i_blocks = (size + (1 << inode->i_blkbits) - 1) >> inode->i_blkbits; - + if ((size << 1) >= ci->i_max_size && (ci->i_reported_size << 1) < ci->i_max_size) { spin_unlock(&inode->i_lock); @@ -926,8 +930,8 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, int wake = 0; int writeback_now = 0; int invalidate = 0; - - dout(10, "handle_cap_grant inode %p ci %p mds%d seq %d\n", + + dout(10, "handle_cap_grant inode %p ci %p mds%d seq %d\n", inode, ci, mds, seq); dout(10, " size %llu max_size %llu, i_size %llu\n", size, max_size, inode->i_size); @@ -945,7 +949,7 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, dout(10, "no cap on ino %llx from mds%d, ignoring\n", ci->i_ceph_ino, mds); goto out; - } + } /* size change? */ if (size > inode->i_size) { @@ -971,19 +975,19 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, ceph_decode_timespec(&atime, &grant->atime); ceph_decode_timespec(&ctime, &grant->ctime); if (timespec_compare(&mtime, &inode->i_mtime) > 0) { - dout(10, "mtime %lu.%09ld -> %lu.%.09ld\n", + dout(10, "mtime %lu.%09ld -> %lu.%.09ld\n", mtime.tv_sec, mtime.tv_nsec, inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec); inode->i_mtime = mtime; } if (timespec_compare(&ctime, &inode->i_ctime) > 0) { - dout(10, "ctime %lu.%09ld -> %lu.%.09ld\n", + dout(10, "ctime %lu.%09ld -> %lu.%.09ld\n", ctime.tv_sec, ctime.tv_nsec, inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec); inode->i_ctime = ctime; } if (timespec_compare(&atime, &inode->i_atime) > 0) { - dout(10, "atime %lu.%09ld -> %lu.%09ld\n", + dout(10, "atime %lu.%09ld -> %lu.%09ld\n", atime.tv_sec, atime.tv_nsec, inode->i_atime.tv_sec, inode->i_atime.tv_nsec); inode->i_atime = atime; @@ -995,7 +999,7 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, used = __ceph_caps_used(ci); dout(10, " my wanted = %d, used = %d\n", wanted, used); if (wanted != le32_to_cpu(grant->wanted)) { - dout(10, "mds wanted %d -> %d\n", le32_to_cpu(grant->wanted), + dout(10, "mds wanted %d -> %d\n", le32_to_cpu(grant->wanted), wanted); grant->wanted = cpu_to_le32(wanted); } @@ -1008,7 +1012,7 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, dout(10, "revocation: %d -> %d\n", cap->issued, newcaps); if ((cap->issued & ~newcaps) & CEPH_CAP_RDCACHE) invalidate = 1; - if ((used & ~newcaps) & CEPH_CAP_WRBUFFER) + if ((used & ~newcaps) & CEPH_CAP_WRBUFFER) writeback_now = 1; /* will delay ack */ else { cap->implemented = newcaps; @@ -1017,12 +1021,12 @@ int ceph_handle_cap_grant(struct inode *inode, struct ceph_mds_file_caps *grant, grant->max_size = 0; /* don't re-request */ ceph_encode_timespec(&grant->mtime, &inode->i_mtime); ceph_encode_timespec(&grant->atime, &inode->i_atime); - reply = 1; + reply = 1; } cap->issued = newcaps; goto out; } - + /* grant or no-op */ if (cap->issued == newcaps) { dout(10, "caps unchanged: %d -> %d\n", cap->issued, newcaps); @@ -1119,7 +1123,7 @@ int ceph_handle_cap_trunc(struct inode *inode, struct ceph_mds_file_caps *trunc, int seq = le32_to_cpu(trunc->seq); int err; u64 size = le64_to_cpu(trunc->size); - dout(10, "handle_cap_trunc inode %p ci %p mds%d seq %d\n", inode, ci, + dout(10, "handle_cap_trunc inode %p ci %p mds%d seq %d\n", inode, ci, mds, seq); err = apply_cap_truncate(inode, size); if (err) @@ -1146,7 +1150,7 @@ void ceph_take_cap_refs(struct ceph_inode_info *ci, int got) spin_lock(&ci->vfs_inode.i_lock); __take_cap_refs(ci, got); spin_unlock(&ci->vfs_inode.i_lock); -} +} int ceph_get_cap_refs(struct ceph_inode_info *ci, int need, int want, int *got, loff_t offset) @@ -1197,8 +1201,8 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) dout(10, "put_cap_refs on %p had %d %s\n", &ci->vfs_inode, had, last ? "last":""); - - if (last) + + if (last) ceph_check_caps(ci, 1); } @@ -1212,11 +1216,11 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr) last++; BUG_ON(ci->i_wrbuffer_ref < 0); spin_unlock(&ci->vfs_inode.i_lock); - + dout(10, "put_wrbuffer_cap_refs on %p nr %d %s\n", &ci->vfs_inode, nr, last ? "last":""); - - if (last) + + if (last) ceph_check_caps(ci, 1); } @@ -1224,7 +1228,7 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr) /* * symlinks */ -static void * ceph_sym_follow_link(struct dentry *dentry, struct nameidata *nd) +static void *ceph_sym_follow_link(struct dentry *dentry, struct nameidata *nd) { struct ceph_inode_info *ci = ceph_inode(dentry->d_inode); nd_set_link(nd, ci->i_symlink); @@ -1240,8 +1244,8 @@ const struct inode_operations ceph_symlink_iops = { /* * generics */ -static struct ceph_mds_request *prepare_setattr(struct ceph_mds_client *mdsc, - struct dentry *dentry, +static struct ceph_mds_request *prepare_setattr(struct ceph_mds_client *mdsc, + struct dentry *dentry, int ia_valid, int op) { char *path; @@ -1252,7 +1256,7 @@ static struct ceph_mds_request *prepare_setattr(struct ceph_mds_client *mdsc, if (ia_valid & ATTR_FILE) { dout(5, "prepare_setattr dentry %p (inode %llx)\n", dentry, ceph_ino(dentry->d_inode)); - req = ceph_mdsc_create_request(mdsc, op, + req = ceph_mdsc_create_request(mdsc, op, ceph_ino(dentry->d_inode), "", 0, 0); } else { @@ -1277,7 +1281,7 @@ static int ceph_setattr_chown(struct dentry *dentry, struct iattr *attr) int err; req = prepare_setattr(mdsc, dentry, ia_valid, CEPH_MDS_OP_CHOWN); - if (IS_ERR(req)) + if (IS_ERR(req)) return PTR_ERR(req); reqh = req->r_request->front.iov_base; if (ia_valid & ATTR_UID) @@ -1308,7 +1312,7 @@ static int ceph_setattr_chmod(struct dentry *dentry, struct iattr *attr) int err; req = prepare_setattr(mdsc, dentry, attr->ia_valid, CEPH_MDS_OP_CHMOD); - if (IS_ERR(req)) + if (IS_ERR(req)) return PTR_ERR(req); reqh = req->r_request->front.iov_base; reqh->args.chmod.mode = cpu_to_le32(attr->ia_mode); @@ -1332,7 +1336,7 @@ static int ceph_setattr_time(struct dentry *dentry, struct iattr *attr) struct ceph_mds_request *req; struct ceph_mds_request_head *reqh; int err; - + /* if i hold CAP_EXCL, i can change [am]time any way i like */ if (ceph_caps_issued(ci) & CEPH_CAP_EXCL) { dout(10, "utime holding EXCL, doing locally\n"); @@ -1361,14 +1365,14 @@ static int ceph_setattr_time(struct dentry *dentry, struct iattr *attr) if (ceph_inode_lease_valid(inode, CEPH_LOCK_ICONTENT) && !(((ia_valid & ATTR_ATIME) && !timespec_equal(&inode->i_atime, &attr->ia_atime)) || - ((ia_valid & ATTR_MTIME) && + ((ia_valid & ATTR_MTIME) && !timespec_equal(&inode->i_mtime, &attr->ia_mtime)))) { dout(10, "lease indicates utimes is a no-op\n"); return 0; } req = prepare_setattr(mdsc, dentry, ia_valid, CEPH_MDS_OP_UTIME); - if (IS_ERR(req)) + if (IS_ERR(req)) return PTR_ERR(req); reqh = req->r_request->front.iov_base; ceph_encode_timespec(&reqh->args.utime.mtime, &attr->ia_mtime); @@ -1413,10 +1417,10 @@ static int ceph_setattr_size(struct dentry *dentry, struct iattr *attr) if (ceph_inode_lease_valid(inode, CEPH_LOCK_ICONTENT) && attr->ia_size < inode->i_size) { dout(10, "lease indicates truncate is a no-op\n"); - return 0; + return 0; } - req = prepare_setattr(mdsc, dentry, ia_valid, CEPH_MDS_OP_TRUNCATE); - if (IS_ERR(req)) + req = prepare_setattr(mdsc, dentry, ia_valid, CEPH_MDS_OP_TRUNCATE); + if (IS_ERR(req)) return PTR_ERR(req); reqh = req->r_request->front.iov_base; reqh->args.truncate.length = cpu_to_le64(attr->ia_size); @@ -1442,25 +1446,25 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) return err; /* gratuitous debug output */ - if (ia_valid & ATTR_UID) + if (ia_valid & ATTR_UID) dout(10, "setattr: uid %d -> %d\n", inode->i_uid, attr->ia_uid); - if (ia_valid & ATTR_GID) + if (ia_valid & ATTR_GID) dout(10, "setattr: gid %d -> %d\n", inode->i_uid, attr->ia_uid); - if (ia_valid & ATTR_MODE) - dout(10, "setattr: mode %o -> %o\n", inode->i_mode, + if (ia_valid & ATTR_MODE) + dout(10, "setattr: mode %o -> %o\n", inode->i_mode, attr->ia_mode); - if (ia_valid & ATTR_SIZE) - dout(10, "setattr: size %lld -> %lld\n", inode->i_size, + if (ia_valid & ATTR_SIZE) + dout(10, "setattr: size %lld -> %lld\n", inode->i_size, attr->ia_size); - if (ia_valid & ATTR_ATIME) - dout(10, "setattr: atime %ld.%ld -> %ld.%ld\n", - inode->i_atime.tv_sec, inode->i_atime.tv_nsec, + if (ia_valid & ATTR_ATIME) + dout(10, "setattr: atime %ld.%ld -> %ld.%ld\n", + inode->i_atime.tv_sec, inode->i_atime.tv_nsec, attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec); - if (ia_valid & ATTR_MTIME) - dout(10, "setattr: mtime %ld.%ld -> %ld.%ld\n", - inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec, + if (ia_valid & ATTR_MTIME) + dout(10, "setattr: mtime %ld.%ld -> %ld.%ld\n", + inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec, attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec); - if (ia_valid & ATTR_FILE) + if (ia_valid & ATTR_FILE) dout(10, "setattr: ATTR_FILE ... hrm!\n"); /* chown */ @@ -1469,7 +1473,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) if (err) return err; } - + /* chmod? */ if (ia_valid & ATTR_MODE) { err = ceph_setattr_chmod(dentry, attr); @@ -1502,7 +1506,7 @@ int ceph_inode_revalidate(struct inode *inode, int mask) return ceph_do_lookup(inode->i_sb, d_find_alias(inode), mask); } -int ceph_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, +int ceph_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { int err = 0; @@ -1511,7 +1515,7 @@ int ceph_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, err = ceph_inode_revalidate(dentry->d_inode, CEPH_STAT_MASK_INODE_ALL); dout(30, "ceph_inode_getattr returned %d\n", err); - if (!err) + if (!err) generic_fillattr(dentry->d_inode, stat); return err; } diff --git a/src/kernel/ktcp.c b/src/kernel/ktcp.c index 57eec78e9e651..dc70f01ef8d63 100644 --- a/src/kernel/ktcp.c +++ b/src/kernel/ktcp.c @@ -5,17 +5,17 @@ #include "messenger.h" #include "ktcp.h" -int ceph_debug_tcp = 0; +int ceph_debug_tcp; #define DOUT_VAR ceph_debug_tcp #define DOUT_PREFIX "tcp: " #include "super.h" -struct workqueue_struct *recv_wq = NULL; /* receive work queue */ -struct workqueue_struct *send_wq = NULL; /* send work queue */ -struct workqueue_struct *accept_wq = NULL; /* accept work queue */ +struct workqueue_struct *recv_wq; /* receive work queue */ +struct workqueue_struct *send_wq; /* send work queue */ +struct workqueue_struct *accept_wq; /* accept work queue */ /* - * socket callback functions + * socket callback functions */ /* listen socket received a connect */ @@ -32,7 +32,7 @@ static void ceph_accept_ready(struct sock *sk, int count_unused) /* Data available on socket or listen socket received a connect */ static void ceph_data_ready(struct sock *sk, int count_unused) { - struct ceph_connection *con = + struct ceph_connection *con = (struct ceph_connection *)sk->sk_user_data; if (con && (sk->sk_state != TCP_CLOSE_WAIT)) { dout(30, "ceph_data_ready on %p state = %lu, queuing rwork\n", @@ -44,16 +44,16 @@ static void ceph_data_ready(struct sock *sk, int count_unused) /* socket has bufferspace for writing */ static void ceph_write_space(struct sock *sk) { - struct ceph_connection *con = + struct ceph_connection *con = (struct ceph_connection *)sk->sk_user_data; - dout(30, "ceph_write_space %p state = %lu\n", con, con->state); + dout(30, "ceph_write_space %p state = %lu\n", con, con->state); /* only queue to workqueue if a WRITE is pending */ if (con && test_bit(WRITE_PENDING, &con->state)) { - dout(30, "ceph_write_space %p queuing write work\n", con); + dout(30, "ceph_write_space %p queuing write work\n", con); ceph_queue_write(con); - } + } /* Since we have our own write_space, Clear the SOCK_NOSPACE flag */ clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags); } @@ -61,35 +61,35 @@ static void ceph_write_space(struct sock *sk) /* sockets state has change */ static void ceph_state_change(struct sock *sk) { - struct ceph_connection *con = + struct ceph_connection *con = (struct ceph_connection *)sk->sk_user_data; if (con == NULL) return; - dout(30, "ceph_state_change %p state = %lu sk_state = %u\n", + dout(30, "ceph_state_change %p state = %lu sk_state = %u\n", con, con->state, sk->sk_state); - switch (sk->sk_state) { - case TCP_CLOSE: - dout(30, "ceph_state_change TCP_CLOSE\n"); - case TCP_CLOSE_WAIT: - dout(30, "ceph_state_change TCP_CLOSE_WAIT\n"); - set_bit(SOCK_CLOSE, &con->state); - if (test_bit(CONNECTING, &con->state)) - con->error_msg = "connection refused"; - else - con->error_msg = "socket closed"; - ceph_queue_write(con); - break; - case TCP_ESTABLISHED: - dout(30, "ceph_state_change TCP_ESTABLISHED\n"); - ceph_write_space(sk); - break; - } + switch (sk->sk_state) { + case TCP_CLOSE: + dout(30, "ceph_state_change TCP_CLOSE\n"); + case TCP_CLOSE_WAIT: + dout(30, "ceph_state_change TCP_CLOSE_WAIT\n"); + set_bit(SOCK_CLOSE, &con->state); + if (test_bit(CONNECTING, &con->state)) + con->error_msg = "connection refused"; + else + con->error_msg = "socket closed"; + ceph_queue_write(con); + break; + case TCP_ESTABLISHED: + dout(30, "ceph_state_change TCP_ESTABLISHED\n"); + ceph_write_space(sk); + break; + } } /* make a listening socket active by setting up the data ready call back */ -static void listen_sock_callbacks(struct socket *sock, +static void listen_sock_callbacks(struct socket *sock, struct ceph_messenger *msgr) { struct sock *sk = sock->sk; @@ -100,11 +100,11 @@ static void listen_sock_callbacks(struct socket *sock, /* make a socket active by setting up the call back functions */ static void set_sock_callbacks(struct socket *sock, struct ceph_connection *con) { - struct sock *sk = sock->sk; - sk->sk_user_data = (void *)con; - sk->sk_data_ready = ceph_data_ready; - sk->sk_write_space = ceph_write_space; - sk->sk_state_change = ceph_state_change; + struct sock *sk = sock->sk; + sk->sk_user_data = (void *)con; + sk->sk_data_ready = ceph_data_ready; + sk->sk_write_space = ceph_write_space; + sk->sk_state_change = ceph_state_change; } /* * initiate connection to a remote socket. @@ -114,29 +114,29 @@ int ceph_tcp_connect(struct ceph_connection *con) int ret; struct sockaddr *paddr = (struct sockaddr *)&con->peer_addr.ipaddr; - ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &con->sock); - if (ret < 0) { - derr(1, "connect sock_create_kern error: %d\n", ret); - goto done; - } - set_sock_callbacks(con->sock, con); - + ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &con->sock); + if (ret < 0) { + derr(1, "connect sock_create_kern error: %d\n", ret); + goto done; + } + set_sock_callbacks(con->sock, con); + ret = con->sock->ops->connect(con->sock, paddr, - sizeof(struct sockaddr_in), O_NONBLOCK); - if (ret == -EINPROGRESS) { - dout(20, "connect EINPROGRESS sk_state = = %u\n", + sizeof(struct sockaddr_in), O_NONBLOCK); + if (ret == -EINPROGRESS) { + dout(20, "connect EINPROGRESS sk_state = = %u\n", con->sock->sk->sk_state); return 0; } - if (ret < 0) { - /* TBD check for fatal errors, retry if not fatal.. */ - derr(1, "connect %u.%u.%u.%u:%u error: %d\n", + if (ret < 0) { + /* TBD check for fatal errors, retry if not fatal.. */ + derr(1, "connect %u.%u.%u.%u:%u error: %d\n", IPQUADPORT(*(struct sockaddr_in *)paddr), ret); - sock_release(con->sock); - con->sock = NULL; - } + sock_release(con->sock); + con->sock = NULL; + } done: - return ret; + return ret; } /* @@ -151,12 +151,12 @@ int ceph_tcp_listen(struct ceph_messenger *msgr) int nlen; ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); - if (ret < 0) { + if (ret < 0) { derr(0, "sock_create_kern error: %d\n", ret); return ret; } ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&optval, sizeof(optval)); + (char *)&optval, sizeof(optval)); if (ret < 0) { derr(0, "Failed to set SO_REUSEADDR: %d\n", ret); goto err; @@ -170,7 +170,7 @@ int ceph_tcp_listen(struct ceph_messenger *msgr) derr(0, "Failed to bind: %d\n", ret); goto err; } - + /* what port did we bind to? */ nlen = sizeof(*myaddr); ret = sock->ops->getname(sock, (struct sockaddr *)myaddr, &nlen, 0); @@ -181,7 +181,7 @@ int ceph_tcp_listen(struct ceph_messenger *msgr) dout(10, "listen on port %d\n", ntohs(myaddr->sin_port)); ret = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, - (char *)&optval, sizeof(optval)); + (char *)&optval, sizeof(optval)); if (ret < 0) { derr(0, "Failed to set SO_KEEPALIVE: %d\n", ret); goto err; @@ -197,8 +197,8 @@ int ceph_tcp_listen(struct ceph_messenger *msgr) goto err; } - /* setup callbacks */ - listen_sock_callbacks(msgr->listen_sock, msgr); + /* setup callbacks */ + listen_sock_callbacks(msgr->listen_sock, msgr); return ret; err: @@ -216,26 +216,26 @@ int ceph_tcp_accept(struct socket *sock, struct ceph_connection *con) int len; - ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &con->sock); - if (ret < 0) { - derr(0, "sock_create_kern error: %d\n", ret); - goto done; - } + ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &con->sock); + if (ret < 0) { + derr(0, "sock_create_kern error: %d\n", ret); + goto done; + } - ret = sock->ops->accept(sock, con->sock, O_NONBLOCK); + ret = sock->ops->accept(sock, con->sock, O_NONBLOCK); /* ret = kernel_accept(sock, &new_sock, sock->file->f_flags); */ - if (ret < 0) { + if (ret < 0) { derr(0, "accept error: %d\n", ret); goto err; } - /* setup callbacks */ - set_sock_callbacks(con->sock, con); + /* setup callbacks */ + set_sock_callbacks(con->sock, con); con->sock->ops = sock->ops; con->sock->type = sock->type; ret = con->sock->ops->getname(con->sock, paddr, &len, 2); - if (ret < 0) { + if (ret < 0) { derr(0, "getname error: %d\n", ret); goto err; } @@ -256,11 +256,8 @@ int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len) struct msghdr msg = {.msg_flags = 0}; int rlen = 0; /* length read */ - //dout(30, "recvmsg %p len %d %p-%p\n", sock, (int)len, buf, buf+len); msg.msg_flags |= MSG_DONTWAIT | MSG_NOSIGNAL; - /* receive one kvec for now... */ rlen = kernel_recvmsg(sock, &msg, &iov, 1, len, msg.msg_flags); - //dout(30, "recvmsg %p len %d ret = %d\n", sock, (int)len, rlen); return(rlen); } @@ -268,16 +265,14 @@ int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len) /* * Send a message this may return after partial send */ -int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, +int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, size_t kvlen, size_t len) { struct msghdr msg = {.msg_flags = 0}; int rlen = 0; - //dout(30, "sendmsg %p len %d\n", sock, (int)len); msg.msg_flags |= MSG_DONTWAIT | MSG_NOSIGNAL; rlen = kernel_sendmsg(sock, &msg, iov, kvlen, len); - //dout(30, "sendmsg %p len %d ret = %d\n", sock, (int)len, rlen); return(rlen); } @@ -287,48 +282,48 @@ int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, int ceph_workqueue_init(void) { - int ret = 0; - - dout(20, "entered work_init\n"); - /* - * Create a num CPU threads to handle receive requests - * note: we can create more threads if needed to even out - * the scheduling of multiple requests.. - */ - recv_wq = create_workqueue("ceph-recv"); - ret = IS_ERR(recv_wq); - if (ret) { - derr(0, "receive worker failed to start: %d\n", ret); - destroy_workqueue(recv_wq); - return ret; - } - - /* - * Create a single thread to handle send requests - * note: may use same thread pool as receive workers later... - */ - send_wq = create_singlethread_workqueue("ceph-send"); - ret = IS_ERR(send_wq); - if (ret) { - derr(0, "send worker failed to start: %d\n", ret); - destroy_workqueue(send_wq); - return ret; - } - - /* - * Create a single thread to handle send requests - * note: may use same thread pool as receive workers later... - */ - accept_wq = create_singlethread_workqueue("ceph-accept"); - ret = IS_ERR(accept_wq); - if (ret) { - derr(0, "accept worker failed to start: %d\n", ret); - destroy_workqueue(accept_wq); - return ret; - } - dout(20, "successfully created wrkqueues\n"); - - return(ret); + int ret = 0; + + dout(20, "entered work_init\n"); + /* + * Create a num CPU threads to handle receive requests + * note: we can create more threads if needed to even out + * the scheduling of multiple requests.. + */ + recv_wq = create_workqueue("ceph-recv"); + ret = IS_ERR(recv_wq); + if (ret) { + derr(0, "receive worker failed to start: %d\n", ret); + destroy_workqueue(recv_wq); + return ret; + } + + /* + * Create a single thread to handle send requests + * note: may use same thread pool as receive workers later... + */ + send_wq = create_singlethread_workqueue("ceph-send"); + ret = IS_ERR(send_wq); + if (ret) { + derr(0, "send worker failed to start: %d\n", ret); + destroy_workqueue(send_wq); + return ret; + } + + /* + * Create a single thread to handle send requests + * note: may use same thread pool as receive workers later... + */ + accept_wq = create_singlethread_workqueue("ceph-accept"); + ret = IS_ERR(accept_wq); + if (ret) { + derr(0, "accept worker failed to start: %d\n", ret); + destroy_workqueue(accept_wq); + return ret; + } + dout(20, "successfully created wrkqueues\n"); + + return(ret); } /* @@ -336,7 +331,7 @@ int ceph_workqueue_init(void) */ void ceph_workqueue_shutdown(void) { - destroy_workqueue(accept_wq); - destroy_workqueue(send_wq); - destroy_workqueue(recv_wq); + destroy_workqueue(accept_wq); + destroy_workqueue(send_wq); + destroy_workqueue(recv_wq); } diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index d31c2f354008c..95cc8a28c9c46 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -92,7 +92,7 @@ static int parse_reply_info_trace(void **p, void *end, sizeof(*info->trace_dname) + sizeof(*info->trace_dname_len)), GFP_KERNEL); - if (info->trace_in == NULL) + if (info->trace_in == NULL) goto badmem; info->trace_ilease = (void *)(info->trace_in + numi); @@ -112,7 +112,7 @@ inode: goto bad; info->trace_ilease[numi] = *p; *p += sizeof(struct ceph_mds_reply_lease); - + dentry: if (!numd) goto done; @@ -647,7 +647,7 @@ void revoke_inode_lease(struct ceph_inode_info *ci, int mask) int drop = 0; spin_lock(&ci->vfs_inode.i_lock); - dout(10, "revoke_inode_lease on inode %p, mask %d -> %d\n", + dout(10, "revoke_inode_lease on inode %p, mask %d -> %d\n", &ci->vfs_inode, ci->i_lease_mask, ci->i_lease_mask & ~mask); ci->i_lease_mask &= ~mask; if (ci->i_lease_mask == 0) { @@ -671,19 +671,19 @@ static void trim_session_leases(struct ceph_mds_session *session) struct ceph_inode_info *ci; struct ceph_dentry_info *di; struct dentry *dentry; - + dout(20, "trim_session_leases on session %p\n", session); /* inodes */ while (!list_empty(&session->s_inode_leases)) { - ci = list_first_entry(&session->s_inode_leases, + ci = list_first_entry(&session->s_inode_leases, struct ceph_inode_info, i_lease_item); spin_lock(&ci->vfs_inode.i_lock); if (ci->i_lease_ttl > jiffies) { spin_unlock(&ci->vfs_inode.i_lock); break; } - dout(20, "trim_session_leases inode %p mask %d\n", + dout(20, "trim_session_leases inode %p mask %d\n", &ci->vfs_inode, ci->i_lease_mask); ci->i_lease_session = 0; ci->i_lease_mask = 0; @@ -694,7 +694,7 @@ static void trim_session_leases(struct ceph_mds_session *session) /* dentries */ while (!list_empty(&session->s_dentry_leases)) { - di = list_first_entry(&session->s_dentry_leases, + di = list_first_entry(&session->s_dentry_leases, struct ceph_dentry_info, lease_item); dentry = di->dentry; spin_lock(&dentry->d_lock); @@ -723,7 +723,7 @@ static void remove_session_leases(struct ceph_mds_session *session) /* inodes */ while (!list_empty(&session->s_inode_leases)) { - ci = list_entry(session->s_inode_leases.next, + ci = list_entry(session->s_inode_leases.next, struct ceph_inode_info, i_lease_item); dout(10, "removing lease from inode %p\n", &ci->vfs_inode); revoke_inode_lease(ci, ci->i_lease_mask); @@ -731,7 +731,7 @@ static void remove_session_leases(struct ceph_mds_session *session) /* dentries */ while (!list_empty(&session->s_dentry_leases)) { - di = list_entry(session->s_dentry_leases.next, + di = list_entry(session->s_dentry_leases.next, struct ceph_dentry_info, lease_item); dout(10, "removing lease from dentry %p\n", di->dentry); revoke_dentry_lease(di->dentry); @@ -758,7 +758,7 @@ void ceph_mdsc_handle_session(struct ceph_mds_client *mdsc, spin_lock(&mdsc->lock); session = __get_session(mdsc, mds); down(&session->s_mutex); - + dout(2, "handle_session %p op %d seq %llu\n", session, op, seq); switch (op) { case CEPH_SESSION_OPEN: @@ -858,7 +858,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, head->op = cpu_to_le32(op); head->caller_uid = cpu_to_le32(current->euid); head->caller_gid = cpu_to_le32(current->egid); - dout(10, "create_request euid.egid %d.%d\n", + dout(10, "create_request euid.egid %d.%d\n", current->euid, current->egid); /* encode paths */ @@ -1344,7 +1344,7 @@ void check_new_map(struct ceph_mds_client *mdsc, /* caps */ void ceph_mdsc_send_cap_ack(struct ceph_mds_client *mdsc, __u64 ino, int caps, - int wanted, __u32 seq, __u64 size, __u64 max_size, + int wanted, __u32 seq, __u64 size, __u64 max_size, struct timespec *mtime, struct timespec *atime, int mds) { @@ -1427,7 +1427,7 @@ void ceph_mdsc_handle_filecaps(struct ceph_mds_client *mdsc, if (!inode) { dout(10, "wtf, i don't have ino %lu=%llx? closing out cap\n", inot, ino); - ceph_mdsc_send_cap_ack(mdsc, ino, 0, 0, seq, + ceph_mdsc_send_cap_ack(mdsc, ino, 0, 0, seq, size, 0, 0, 0, mds); goto no_inode; } @@ -1493,7 +1493,7 @@ void ceph_mdsc_handle_lease(struct ceph_mds_client *mdsc, struct ceph_msg *msg) ino_t inot; dout(10, "handle_lease from mds%d\n", mds); - + /* decode */ if (msg->front.iov_len < sizeof(*h) + sizeof(__u32)) goto bad; @@ -1522,7 +1522,7 @@ void ceph_mdsc_handle_lease(struct ceph_mds_client *mdsc, struct ceph_msg *msg) inode = ilookup5(sb, inot, ceph_ino_compare, &ino); #endif dout(20, "action is %d, ino %llx %p\n", h->action, ino, inode); - + BUG_ON(h->action != CEPH_MDS_LEASE_REVOKE); /* for now */ if (inode == NULL) { @@ -1548,7 +1548,7 @@ void ceph_mdsc_handle_lease(struct ceph_mds_client *mdsc, struct ceph_msg *msg) revoke_dentry_lease(dentry); dout(10, "lease revoked on dentry %p\n", dentry); dput(dentry); - } + } release: iput(inode); @@ -1589,7 +1589,7 @@ void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc, struct inode *inode, len += dentry->d_name.len; } else mask &= ~CEPH_LOCK_DN; /* nothing to release */ - } + } ci = ceph_inode(inode); ino = ci->i_ceph_ino; if (ci->i_lease_session && time_after(ci->i_lease_ttl, jiffies)) { @@ -1615,7 +1615,7 @@ void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc, struct inode *inode, lease->action = CEPH_MDS_LEASE_RELEASE; lease->mask = mask; lease->ino = cpu_to_le64(ino); /* ?? */ - *(__le32*)(lease+1) = cpu_to_le32(dnamelen); + *(__le32 *)(lease+1) = cpu_to_le32(dnamelen); if (dentry) memcpy((void *)(lease + 1) + 4, dentry->d_name.name, dnamelen); @@ -1644,7 +1644,7 @@ void delayed_work(struct work_struct *work) container_of(work, struct ceph_mds_client, delayed_work.work); int renew_interval = mdsc->mdsmap->m_cap_bit_timeout >> 1; int renew_caps = (jiffies >= HZ*renew_interval + mdsc->last_renew_caps); - + dout(10, "delayed_work on %p renew_caps=%d\n", mdsc, renew_caps); /* renew caps */ diff --git a/src/kernel/mds_client.h b/src/kernel/mds_client.h index 96aa5f40a7173..7126f6570804e 100644 --- a/src/kernel/mds_client.h +++ b/src/kernel/mds_client.h @@ -30,7 +30,7 @@ struct ceph_mds_reply_info { char **trace_dname; __u32 *trace_dname_len; struct ceph_mds_reply_lease **trace_dlease; - + struct ceph_mds_reply_dirfrag *dir_dir; int dir_nr; struct ceph_mds_reply_lease **dir_ilease; @@ -108,7 +108,7 @@ struct ceph_mds_client { unsigned long last_renew_caps; }; -extern const char* ceph_mds_op_name(int op); +extern const char *ceph_mds_op_name(int op); extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client); @@ -129,7 +129,7 @@ extern void ceph_mdsc_handle_filecaps(struct ceph_mds_client *mdsc, extern void ceph_mdsc_handle_lease(struct ceph_mds_client *mdsc, struct ceph_msg *msg); -extern void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc, +extern void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc, struct inode *inode, struct dentry *dn, int mask); @@ -141,11 +141,11 @@ extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, struct ceph_mds_request *req); extern void ceph_mdsc_put_request(struct ceph_mds_request *req); -extern void ceph_mdsc_send_cap_ack(struct ceph_mds_client *mdsc, __u64 ino, - int caps, int wanted, __u32 seq, - __u64 size, __u64 max_size, - struct timespec *mtime, +extern void ceph_mdsc_send_cap_ack(struct ceph_mds_client *mdsc, __u64 ino, + int caps, int wanted, __u32 seq, + __u64 size, __u64 max_size, + struct timespec *mtime, struct timespec *atime, int mds); - + #endif diff --git a/src/kernel/mdsmap.c b/src/kernel/mdsmap.c index 9b0a43692a20f..049d58f53a4ad 100644 --- a/src/kernel/mdsmap.c +++ b/src/kernel/mdsmap.c @@ -28,17 +28,18 @@ int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m) char r; /* count */ - for (i=0; im_max_mds; i++) - if (m->m_state > 0) n++; - if (n == 0) + for (i = 0; i < m->m_max_mds; i++) + if (m->m_state > 0) + n++; + if (n == 0) return -1; - + /* pick */ get_random_bytes(&r, 1); n = r % n; i = 0; - for (i=0; n>0; i++, n--) - while (m->m_state[i] <= 0) + for (i = 0; n > 0; i++, n--) + while (m->m_state[i] <= 0) i++; return i; @@ -57,9 +58,9 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) int i, n; __u32 mds; int err = -EINVAL; - + m = kzalloc(sizeof(*m), GFP_KERNEL); - if (m == NULL) + if (m == NULL) return ERR_PTR(-ENOMEM); ceph_decode_need(p, end, 10*sizeof(__u32), bad); @@ -78,11 +79,11 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) m->m_state = kzalloc(m->m_max_mds*sizeof(*m->m_state), GFP_KERNEL); if (m->m_addr == NULL || m->m_state == NULL) goto badmem; - + /* state */ ceph_decode_32(p, n); ceph_decode_need(p, end, n*2*sizeof(__u32), bad); - for (i=0; i= m->m_max_mds) goto bad; @@ -92,14 +93,14 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) /* state_seq */ ceph_decode_32_safe(p, end, n, bad); *p += n*(sizeof(__u32)+sizeof(__u64)); - + /* mds_inst */ ceph_decode_32_safe(p, end, n, bad); - ceph_decode_need(p, end, + ceph_decode_need(p, end, n*(sizeof(__u32)+sizeof(struct ceph_entity_name)+ - sizeof(struct ceph_entity_addr)), + sizeof(struct ceph_entity_addr)), bad); - for (i=0; i= m->m_max_mds) goto bad; diff --git a/src/kernel/messenger.c b/src/kernel/messenger.c index f20981769e80f..02a7c6d783ef9 100644 --- a/src/kernel/messenger.c +++ b/src/kernel/messenger.c @@ -8,7 +8,7 @@ #include "messenger.h" #include "ktcp.h" -int ceph_debug_msgr = 0; +int ceph_debug_msgr; #define DOUT_VAR ceph_debug_msgr #define DOUT_PREFIX "msgr: " #include "super.h" @@ -69,7 +69,7 @@ static struct ceph_connection *new_connection(struct ceph_messenger *msgr) static unsigned long hash_addr(struct ceph_entity_addr *addr) { unsigned long key; - key = *(__u32*)&addr->ipaddr.sin_addr.s_addr; + key = *(__u32 *)&addr->ipaddr.sin_addr.s_addr; key ^= addr->ipaddr.sin_port; return key; } @@ -77,7 +77,7 @@ static unsigned long hash_addr(struct ceph_entity_addr *addr) /* * get an existing connection, if any, for given addr */ -static struct ceph_connection *__get_connection(struct ceph_messenger *msgr, +static struct ceph_connection *__get_connection(struct ceph_messenger *msgr, struct ceph_entity_addr *addr) { struct ceph_connection *con = NULL; @@ -153,7 +153,7 @@ static void __add_connection(struct ceph_messenger *msgr, } } -static void add_connection_accepting(struct ceph_messenger *msgr, +static void add_connection_accepting(struct ceph_messenger *msgr, struct ceph_connection *con) { atomic_inc(&con->nref); @@ -185,7 +185,7 @@ static void __remove_connection(struct ceph_messenger *msgr, key = hash_addr(&con->peer_addr); if (list_empty(&con->list_bucket)) { /* last one */ - dout(20, "__remove_connection %p and bucket %lu\n", + dout(20, "__remove_connection %p and bucket %lu\n", con, key); radix_tree_delete(&msgr->con_open, key); } else { @@ -197,7 +197,7 @@ static void __remove_connection(struct ceph_messenger *msgr, dout(20, "__remove_connection adjusting bucket" " for %lu to next item, %p\n", key, con->list_bucket.next); - radix_tree_replace_slot(slot, + radix_tree_replace_slot(slot, con->list_bucket.next); } list_del_init(&con->list_bucket); @@ -232,7 +232,7 @@ void ceph_queue_delayed_write(struct ceph_connection *con) { dout(40, "ceph_queue_delayed_write %p delay %lu\n", con, con->delay); atomic_inc(&con->nref); - if (!queue_delayed_work(send_wq, &con->swork, + if (!queue_delayed_work(send_wq, &con->swork, round_jiffies_relative(con->delay))) { dout(40, "ceph_queue_delayed_write %p - already queued\n", con); put_connection(con); @@ -277,15 +277,18 @@ static void ceph_send_fault(struct ceph_connection *con) con->sock = NULL; set_bit(NEW, &con->state); - /* If there are no messages in the queue, place the connection - * in a STANDBY state otherwise retry with delay */ + /* + * If there are no messages in the queue, place the + * connection in a STANDBY state otherwise retry with + * delay + */ if (list_empty(&con->out_queue)) { dout(10, "setting STANDBY bit\n"); set_bit(STANDBY, &con->state); return; } - if (!test_and_clear_bit(CONNECTING, &con->state)){ + if (!test_and_clear_bit(CONNECTING, &con->state)) { derr(1, "CONNECTING bit not set\n"); /* TBD: reset buffer correctly */ /* reset buffer */ @@ -329,7 +332,7 @@ static int write_partial_kvec(struct ceph_connection *con) while (con->out_kvec_bytes > 0) { ret = ceph_tcp_sendmsg(con->sock, con->out_kvec_cur, con->out_kvec_left, con->out_kvec_bytes); - if (ret <= 0) + if (ret <= 0) goto out; con->out_kvec_bytes -= ret; if (con->out_kvec_bytes == 0) @@ -355,14 +358,14 @@ out: return ret; /* done! */ } -static int write_partial_msg_pages(struct ceph_connection *con, +static int write_partial_msg_pages(struct ceph_connection *con, struct ceph_msg *msg) { struct kvec kv; int ret; unsigned data_len = le32_to_cpu(msg->hdr.data_len); - dout(30, "write_partial_msg_pages %p on %d/%d offset %d\n", + dout(30, "write_partial_msg_pages %p on %d/%d offset %d\n", con, con->out_msg_pos.page, con->out_msg->nr_pages, con->out_msg_pos.page_pos); @@ -372,7 +375,7 @@ static int write_partial_msg_pages(struct ceph_connection *con, kv.iov_len = min((int)(PAGE_SIZE - con->out_msg_pos.page_pos), (int)(data_len - con->out_msg_pos.data_pos)); ret = ceph_tcp_sendmsg(con->sock, &kv, 1, kv.iov_len); - if (ret <= 0) + if (ret <= 0) goto out; con->out_msg_pos.data_pos += ret; con->out_msg_pos.page_pos += ret; @@ -396,7 +399,7 @@ out: */ static void prepare_write_message(struct ceph_connection *con) { - struct ceph_msg *m = list_entry(con->out_queue.next, + struct ceph_msg *m = list_entry(con->out_queue.next, struct ceph_msg, list_head); /* move to sending/sent list */ @@ -460,7 +463,7 @@ static void prepare_write_connect(struct ceph_messenger *msgr, set_bit(WRITE_PENDING, &con->state); } -static void prepare_write_accept_announce(struct ceph_messenger *msgr, +static void prepare_write_accept_announce(struct ceph_messenger *msgr, struct ceph_connection *con) { con->out_kvec[0].iov_base = &msgr->inst.addr; @@ -505,7 +508,7 @@ static void try_write(struct work_struct *work) int ret = 1; dout(30, "try_write start %p state %lu nref %d\n", con, con->state, - atomic_read(&con->nref)); + atomic_read(&con->nref)); if (test_bit(CLOSED, &con->state)) { dout(5, "try_write closed\n"); @@ -525,7 +528,7 @@ more: con->connect_seq++; prepare_write_connect(msgr, con); set_bit(CONNECTING, &con->state); - dout(5, "try_write initiating connect on %p new state %lu\n", + dout(5, "try_write initiating connect on %p new state %lu\n", con, con->state); ret = ceph_tcp_connect(con); if (ret < 0) { @@ -552,7 +555,7 @@ more: if (ret == 0) goto done; if (ret < 0) { - dout(30, "try_write write_partial_msg_pages err %d\n", + dout(30, "try_write write_partial_msg_pages err %d\n", ret); goto done; } @@ -569,7 +572,7 @@ more: /* hmm, nothing to do! No more writes pending? */ dout(30, "try_write nothing else to write.\n"); spin_unlock(&con->out_queue_lock); - if (con->delay > 0) + if (con->delay > 0) con->delay = BASE_DELAY_INTERVAL; goto done; } @@ -620,7 +623,8 @@ static int read_message_partial(struct ceph_connection *con) left = sizeof(struct ceph_msg_header) - con->in_base_pos; ret = ceph_tcp_recvmsg(con->sock, &m->hdr + con->in_base_pos, left); - if (ret <= 0) return ret; + if (ret <= 0) + return ret; con->in_base_pos += ret; if (con->in_base_pos == sizeof(struct ceph_msg_header)) break; @@ -635,9 +639,10 @@ static int read_message_partial(struct ceph_connection *con) return -ENOMEM; } left = front_len - m->front.iov_len; - ret = ceph_tcp_recvmsg(con->sock, (char*)m->front.iov_base + + ret = ceph_tcp_recvmsg(con->sock, (char *)m->front.iov_base + m->front.iov_len, left); - if (ret <= 0) return ret; + if (ret <= 0) + return ret; m->front.iov_len += ret; } @@ -672,7 +677,7 @@ static int read_message_partial(struct ceph_connection *con) p = kmap(m->pages[con->in_msg_pos.page]); ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos, left); - if (ret <= 0) + if (ret <= 0) return ret; con->in_msg_pos.data_pos += ret; con->in_msg_pos.page_pos += ret; @@ -718,10 +723,11 @@ static int read_ack_partial(struct ceph_connection *con) { while (con->in_base_pos < sizeof(con->in_partial_ack)) { int left = sizeof(con->in_partial_ack) - con->in_base_pos; - int ret = ceph_tcp_recvmsg(con->sock, - (char*)&con->in_partial_ack + + int ret = ceph_tcp_recvmsg(con->sock, + (char *)&con->in_partial_ack + con->in_base_pos, left); - if (ret <= 0) return ret; + if (ret <= 0) + return ret; con->in_base_pos += ret; } return 1; /* done */ @@ -757,10 +763,11 @@ static int read_connect_partial(struct ceph_connection *con) while (con->in_base_pos < to) { int left = to - con->in_base_pos; int have = con->in_base_pos; - ret = ceph_tcp_recvmsg(con->sock, - (char*)&con->actual_peer_addr + have, + ret = ceph_tcp_recvmsg(con->sock, + (char *)&con->actual_peer_addr + have, left); - if (ret <= 0) goto out; + if (ret <= 0) + goto out; con->in_base_pos += ret; } @@ -768,7 +775,8 @@ static int read_connect_partial(struct ceph_connection *con) to += 1; if (con->in_base_pos < to) { ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1); - if (ret <= 0) goto out; + if (ret <= 0) + goto out; con->in_base_pos += ret; } @@ -779,9 +787,10 @@ static int read_connect_partial(struct ceph_connection *con) int left = to - con->in_base_pos; int have = sizeof(con->in_connect_seq) - left; ret = ceph_tcp_recvmsg(con->sock, - (char*)&con->in_connect_seq + + (char *)&con->in_connect_seq + have, left); - if (ret <= 0) goto out; + if (ret <= 0) + goto out; con->in_base_pos += ret; } } @@ -789,7 +798,7 @@ static int read_connect_partial(struct ceph_connection *con) out: dout(20, "read_connect_partial %p end at %d ret %d\n", con, con->in_base_pos, ret); - dout(20, "read_connect_partial peer in connect_seq = %u\n", + dout(20, "read_connect_partial peer in connect_seq = %u\n", le32_to_cpu(con->in_connect_seq)); return ret; /* done */ } @@ -839,7 +848,7 @@ static void process_connect(struct ceph_connection *con) case CEPH_MSGR_TAG_RETRY: dout(10, "process_connect got RETRY my seq = %u, peer_seq = %u\n", - le32_to_cpu(con->out_connect_seq), + le32_to_cpu(con->out_connect_seq), le32_to_cpu(con->in_connect_seq)); con->connect_seq = le32_to_cpu(con->in_connect_seq); prepare_write_connect(con->msgr, con); @@ -862,9 +871,8 @@ static void process_connect(struct ceph_connection *con) con->error_msg = "protocol error"; ceph_send_fault(con); } - if (test_bit(WRITE_PENDING, &con->state)) { + if (test_bit(WRITE_PENDING, &con->state)) ceph_queue_write(con); - } } @@ -881,9 +889,10 @@ static int read_accept_partial(struct ceph_connection *con) while (con->in_base_pos < to) { int left = to - con->in_base_pos; int have = con->in_base_pos; - ret = ceph_tcp_recvmsg(con->sock, - (char*)&con->peer_addr + have, left); - if (ret <= 0) return ret; + ret = ceph_tcp_recvmsg(con->sock, + (char *)&con->peer_addr + have, left); + if (ret <= 0) + return ret; con->in_base_pos += ret; } @@ -892,10 +901,11 @@ static int read_accept_partial(struct ceph_connection *con) while (con->in_base_pos < to) { int left = to - con->in_base_pos; int have = sizeof(con->peer_addr) - left; - ret = ceph_tcp_recvmsg(con->sock, - (char*)&con->in_connect_seq + have, + ret = ceph_tcp_recvmsg(con->sock, + (char *)&con->in_connect_seq + have, left); - if (ret <= 0) return ret; + if (ret <= 0) + return ret; con->in_base_pos += ret; } return 1; /* done */ @@ -907,16 +917,15 @@ static int read_accept_partial(struct ceph_connection *con) * and thus in the same pos in the radix tree) */ static void __replace_connection(struct ceph_messenger *msgr, - struct ceph_connection *old, + struct ceph_connection *old, struct ceph_connection *new) { clear_bit(OPEN, &old->state); /* take old connections message queue */ spin_lock(&old->out_queue_lock); - if (!list_empty(&old->out_queue)) { + if (!list_empty(&old->out_queue)) list_splice_init(&new->out_queue, &old->out_queue); - } spin_unlock(&old->out_queue_lock); new->connect_seq = le32_to_cpu(new->in_connect_seq); @@ -974,7 +983,7 @@ static void process_accept(struct ceph_connection *con) &con->peer_addr)) { /* incoming connection wins.. */ /* replace existing with new connection */ - __replace_connection(msgr, existing, con); + __replace_connection(msgr, existing, con); } else { /* our existing outgoing connection wins.. tell peer to wait for our outgoing @@ -996,7 +1005,7 @@ static void process_accept(struct ceph_connection *con) } else { dout(20, "process_accept no existing connection, opening\n"); __add_connection(msgr, con); - set_bit(OPEN, &con->state); + set_bit(OPEN, &con->state); con->connect_seq = peer_cseq + 1; prepare_write_accept_reply(con, &tag_ready); } @@ -1034,16 +1043,19 @@ more: if (test_bit(ACCEPTING, &con->state)) { dout(20, "try_read accepting\n"); ret = read_accept_partial(con); - if (ret <= 0) goto done; + if (ret <= 0) + goto done; process_accept(con); /* accepted */ goto more; } if (test_bit(CONNECTING, &con->state)) { dout(20, "try_read connecting\n"); ret = read_connect_partial(con); - if (ret <= 0) goto done; + if (ret <= 0) + goto done; process_connect(con); - if (test_bit(CLOSED, &con->state)) goto done; + if (test_bit(CLOSED, &con->state)) + goto done; } if (con->in_base_pos < 0) { @@ -1051,13 +1063,15 @@ more: static char buf[1024]; ret = ceph_tcp_recvmsg(con->sock, buf, min(1024, -con->in_base_pos)); - if (ret <= 0) goto done; + if (ret <= 0) + goto done; con->in_base_pos += ret; goto more; } if (con->in_tag == CEPH_MSGR_TAG_READY) { ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1); - if (ret <= 0) goto done; + if (ret <= 0) + goto done; dout(30, "try_read got tag %d\n", (int)con->in_tag); if (con->in_tag == CEPH_MSGR_TAG_MSG) prepare_read_message(con); @@ -1075,28 +1089,29 @@ more: } if (con->in_tag == CEPH_MSGR_TAG_MSG) { ret = read_message_partial(con); - if (ret <= 0) + if (ret <= 0) goto done; /* if first message, set peer_name */ if (con->peer_name.type == 0) con->peer_name = con->in_msg->hdr.src.name; - dout(1, "===== %p from %s%d %d=%s len %d+%d =====\n", + dout(1, "===== %p from %s%d %d=%s len %d+%d =====\n", con->in_msg, ENTITY_NAME(con->in_msg->hdr.src.name), le32_to_cpu(con->in_msg->hdr.type), ceph_msg_type_name(le32_to_cpu(con->in_msg->hdr.type)), le32_to_cpu(con->in_msg->hdr.front_len), le32_to_cpu(con->in_msg->hdr.data_len)); - msgr->dispatch(con->msgr->parent, con->in_msg); + msgr->dispatch(con->msgr->parent, con->in_msg); con->in_msg = 0; con->in_tag = CEPH_MSGR_TAG_READY; goto more; } if (con->in_tag == CEPH_MSGR_TAG_ACK) { ret = read_ack_partial(con); - if (ret <= 0) goto done; + if (ret <= 0) + goto done; /* got an ack */ process_ack(con, con->in_partial_ack); con->in_tag = CEPH_MSGR_TAG_READY; @@ -1134,20 +1149,20 @@ static void try_accept(struct work_struct *work) /* initialize the msgr connection */ new_con = new_connection(msgr); if (new_con == NULL) { - derr(1, "malloc failure\n"); + derr(1, "malloc failure\n"); goto done; - } + } if (ceph_tcp_accept(msgr->listen_sock, new_con) < 0) { derr(1, "error accepting connection\n"); put_connection(new_con); - goto done; + goto done; } dout(5, "accepted connection \n"); new_con->in_tag = CEPH_MSGR_TAG_READY; new_con->connect_seq = 1; set_bit(ACCEPTING, &new_con->state); - clear_bit(NEW,&new_con->state); + clear_bit(NEW, &new_con->state); prepare_write_accept_announce(msgr, new_con); add_connection_accepting(msgr, new_con); @@ -1226,7 +1241,7 @@ void ceph_messenger_destroy(struct ceph_messenger *msgr) /* * mark a peer down. drop any open connection. */ -void ceph_messenger_mark_down(struct ceph_messenger *msgr, +void ceph_messenger_mark_down(struct ceph_messenger *msgr, struct ceph_entity_addr *addr) { struct ceph_connection *con; @@ -1237,7 +1252,7 @@ void ceph_messenger_mark_down(struct ceph_messenger *msgr, spin_lock(&msgr->con_lock); con = __get_connection(msgr, addr); if (con) { - dout(1, "mark_down %s%d %u.%u.%u.%u:%u (%p)\n", + dout(1, "mark_down %s%d %u.%u.%u.%u:%u (%p)\n", ENTITY_NAME(con->peer_name), IPQUADPORT(con->peer_addr.ipaddr), con); set_bit(CLOSED, &con->state); /* in case there's queued work */ @@ -1249,12 +1264,12 @@ void ceph_messenger_mark_down(struct ceph_messenger *msgr, /* - * queue up an outgoing message. + * queue up an outgoing message. * * this consumes a msg reference. that is, if the caller wants to * keep @msg around, it had better call ceph_msg_get first. */ -int ceph_msg_send(struct ceph_messenger *msgr, struct ceph_msg *msg, +int ceph_msg_send(struct ceph_messenger *msgr, struct ceph_msg *msg, unsigned long timeout) { struct ceph_connection *con, *newcon; @@ -1308,7 +1323,6 @@ int ceph_msg_send(struct ceph_messenger *msgr, struct ceph_msg *msg, le32_to_cpu(msg->hdr.data_len)); dout(2, "ceph_msg_send queuing %p seq %llu for %s%d on %p\n", msg, le64_to_cpu(msg->hdr.seq), ENTITY_NAME(msg->hdr.dst.name), con); - //ceph_msg_get(msg); list_add_tail(&msg->list_head, &con->out_queue); spin_unlock(&con->out_queue_lock); @@ -1372,8 +1386,7 @@ void ceph_msg_put(struct ceph_msg *m) if (atomic_dec_and_test(&m->nref)) { dout(20, "ceph_msg_put last one on %p\n", m); BUG_ON(!list_empty(&m->list_head)); - if (m->front.iov_base) - kfree(m->front.iov_base); + kfree(m->front.iov_base); kfree(m); } } diff --git a/src/kernel/mon_client.c b/src/kernel/mon_client.c index 3d2066cfa7c56..0faa1b997936a 100644 --- a/src/kernel/mon_client.c +++ b/src/kernel/mon_client.c @@ -30,11 +30,11 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end) if (p != end) goto bad; - for (i=0; inum_mon; i++) { + for (i = 0; i < m->num_mon; i++) { dout(30, "monmap_decode mon%d is %u.%u.%u.%u:%u\n", i, IPQUADPORT(m->mon_inst[i].addr.ipaddr)); } - dout(30, "monmap_decode got epoch %d, num_mon %d\n", m->epoch, + dout(30, "monmap_decode got epoch %d, num_mon %d\n", m->epoch, m->num_mon); return m; @@ -49,8 +49,8 @@ bad: int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr) { int i; - for (i=0; inum_mon; i++) - if (ceph_entity_addr_equal(addr, &m->mon_inst[i].addr)) + for (i = 0; i < m->num_mon; i++) + if (ceph_entity_addr_equal(addr, &m->mon_inst[i].addr)) return 1; return 0; } @@ -72,7 +72,7 @@ static int pick_mon(struct ceph_mon_client *monc, int notmon) void ceph_monc_delayed_work(struct delayed_work *dwork, unsigned long *delay) { - dout(5, "ceph_monc_delayed_work started\n"); + dout(5, "ceph_monc_delayed_work started\n"); schedule_delayed_work(dwork, *delay); if (*delay < MAX_DELAY_INTERVAL) *delay *= 2; @@ -82,17 +82,18 @@ void ceph_monc_delayed_work(struct delayed_work *dwork, unsigned long *delay) } /* - * worker function for request mdsmap + * worker function for request mdsmap */ static void work_monc_request_mdsmap(struct work_struct *work) { struct ceph_msg *msg; struct ceph_mds_getmap *h; struct ceph_mon_client *monc = - container_of(work, struct ceph_mon_client, mds_delayed_work.work); + container_of(work, struct ceph_mon_client, + mds_delayed_work.work); int mon = pick_mon(monc, -1); - dout(5, "work_monc_request_mdsmap from mon%d have %u\n", mon, + dout(5, "work_monc_request_mdsmap from mon%d have %u\n", mon, monc->have_mdsmap); msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(*h), 0, 0, 0); @@ -107,22 +108,23 @@ static void work_monc_request_mdsmap(struct work_struct *work) /* keep sending request until we receive mds map */ if (monc->have_mdsmap) - ceph_monc_delayed_work(&monc->mds_delayed_work, + ceph_monc_delayed_work(&monc->mds_delayed_work, &monc->mds_delay); } /* - * worker function for request osdmap + * worker function for request osdmap */ void work_monc_request_osdmap(struct work_struct *work) { struct ceph_msg *msg; struct ceph_osd_getmap *h; struct ceph_mon_client *monc = - container_of(work, struct ceph_mon_client, osd_delayed_work.work); + container_of(work, struct ceph_mon_client, + osd_delayed_work.work); int mon = pick_mon(monc, -1); - - dout(5, "ceph_monc_request_osdmap from mon%d have %u\n", mon, + + dout(5, "ceph_monc_request_osdmap from mon%d have %u\n", mon, monc->have_osdmap); msg = ceph_msg_new(CEPH_MSG_OSD_GETMAP, sizeof(*h), 0, 0, 0); if (IS_ERR(msg)) @@ -134,9 +136,9 @@ void work_monc_request_osdmap(struct work_struct *work) msg->hdr.dst = monc->monmap->mon_inst[mon]; ceph_msg_send(monc->client->msgr, msg, 0); - /* keep sending request until we receive osd map */ - if (monc->have_osdmap) - ceph_monc_delayed_work(&monc->osd_delayed_work, + /* keep sending request until we receive osd map */ + if (monc->have_osdmap) + ceph_monc_delayed_work(&monc->osd_delayed_work, &monc->osd_delay); } @@ -146,7 +148,7 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl) memset(monc, 0, sizeof(*monc)); monc->client = cl; monc->monmap = kzalloc(sizeof(struct ceph_monmap), GFP_KERNEL); - if (monc->monmap == NULL) + if (monc->monmap == NULL) return -ENOMEM; spin_lock_init(&monc->lock); INIT_RADIX_TREE(&monc->statfs_request_tree, GFP_KERNEL); @@ -169,7 +171,7 @@ void ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u32 have) int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, __u32 have) { - dout(5, "ceph_monc_got_mdsmap calling cancel_delayed_work_sync\n"); + dout(5, "ceph_monc_got_mdsmap calling cancel_delayed_work_sync\n"); /* we got map so take map request out of queue */ cancel_delayed_work_sync(&monc->mds_delayed_work); @@ -177,11 +179,11 @@ int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, __u32 have) if (have > monc->have_mdsmap) { monc->have_mdsmap = 0; - dout(5, "ceph_monc_got_mdsmap have %u > wanted %u\n", + dout(5, "ceph_monc_got_mdsmap have %u > wanted %u\n", have, monc->have_mdsmap); return 0; } else { - dout(5, "ceph_monc_got_mdsmap have %u <= wanted %u *****\n", + dout(5, "ceph_monc_got_mdsmap have %u <= wanted %u *****\n", have, monc->have_mdsmap); return -EAGAIN; } @@ -198,7 +200,7 @@ void ceph_monc_request_osdmap(struct ceph_mon_client *monc, int ceph_monc_got_osdmap(struct ceph_mon_client *monc, __u32 have) { - dout(5, "ceph_monc_got_osdmap calling cancel_delayed_work_sync\n"); + dout(5, "ceph_monc_got_osdmap calling cancel_delayed_work_sync\n"); /* we got map so take map request out of queue */ cancel_delayed_work_sync(&monc->osd_delayed_work); @@ -207,11 +209,11 @@ int ceph_monc_got_osdmap(struct ceph_mon_client *monc, __u32 have) if (have > monc->want_osdmap) { monc->want_osdmap = 0; monc->have_osdmap = 0; - dout(5, "ceph_monc_got_osdmap have %u > wanted %u\n", + dout(5, "ceph_monc_got_osdmap have %u > wanted %u\n", have, monc->want_osdmap); return 0; } else { - dout(5, "ceph_monc_got_osdmap have %u <= wanted %u *****\n", + dout(5, "ceph_monc_got_osdmap have %u <= wanted %u *****\n", have, monc->want_osdmap); return -EAGAIN; } @@ -223,13 +225,14 @@ int ceph_monc_got_osdmap(struct ceph_mon_client *monc, __u32 have) * statfs */ -void ceph_monc_handle_statfs_reply(struct ceph_mon_client *monc, struct ceph_msg *msg) +void ceph_monc_handle_statfs_reply(struct ceph_mon_client *monc, + struct ceph_msg *msg) { __u64 tid; struct ceph_mon_statfs_request *req; void *p = msg->front.iov_base; void *end = p + msg->front.iov_len; - + ceph_decode_64_safe(&p, end, tid, bad); dout(10, "handle_statfs_reply %p tid %llu\n", msg, tid); @@ -265,7 +268,7 @@ int send_statfs(struct ceph_mon_client *monc, u64 tid) msg = ceph_msg_new(CEPH_MSG_STATFS, sizeof(tid), 0, 0, 0); if (IS_ERR(msg)) return PTR_ERR(msg); - *(__le64*)msg->front.iov_base = cpu_to_le64(tid); + *(__le64 *)msg->front.iov_base = cpu_to_le64(tid); msg->hdr.dst = monc->monmap->mon_inst[mon]; ceph_msg_send(monc->client->msgr, msg, 0); return 0; @@ -285,9 +288,10 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf) req.last_attempt = jiffies; radix_tree_insert(&monc->statfs_request_tree, req.tid, &req); spin_unlock(&monc->lock); - + /* send request */ - if ((err = send_statfs(monc, req.tid)) < 0) + err = send_statfs(monc, req.tid); + if (err < 0) return err; dout(20, "do_statfs waiting for reply\n"); diff --git a/src/kernel/osd_client.c b/src/kernel/osd_client.c index 6293b77dc5df5..fc9c18c996f88 100644 --- a/src/kernel/osd_client.c +++ b/src/kernel/osd_client.c @@ -66,7 +66,7 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) ceph_decode_need(&p, end, maplen, bad); next = p + maplen; if (osdc->osdmap && osdc->osdmap->epoch+1 == epoch) { - dout(10, "applying incremental map %u len %d\n", + dout(10, "applying incremental map %u len %d\n", epoch, maplen); newmap = apply_incremental(&p, p+maplen, osdc->osdmap); if (IS_ERR(newmap)) { @@ -84,9 +84,9 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) p = next; nr_maps--; } - if (newmap) + if (newmap) goto out; - + /* full maps */ ceph_decode_32_safe(&p, end, nr_maps, bad); dout(30, " %d full maps\n", nr_maps); @@ -95,7 +95,7 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) ceph_decode_32(&p, epoch); ceph_decode_32(&p, maplen); ceph_decode_need(&p, end, maplen, bad); - dout(5, "skipping non-latest full map %u len %d\n", + dout(5, "skipping non-latest full map %u len %d\n", epoch, maplen); p += maplen; nr_maps--; @@ -107,7 +107,7 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) ceph_decode_need(&p, end, maplen, bad); if (osdc->osdmap && osdc->osdmap->epoch >= epoch) { dout(10, "skipping full map %u len %d, " - "older than our %u\n", epoch, maplen, + "older than our %u\n", epoch, maplen, osdc->osdmap->epoch); p += maplen; } else { @@ -123,7 +123,7 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) } } dout(2, "handle_map done\n"); - + ceph_monc_got_osdmap(&osdc->client->monc, osdc->osdmap->epoch); /* kick any pending requests that need kicking */ @@ -139,7 +139,7 @@ bad: -/* +/* * requests */ @@ -161,8 +161,9 @@ struct ceph_msg *new_request_msg(struct ceph_osd_client *osdc, int op) { struct ceph_msg *req; struct ceph_osd_request_head *head; - - req = ceph_msg_new(CEPH_MSG_OSD_OP, sizeof(struct ceph_osd_request_head), 0, 0, 0); + + req = ceph_msg_new(CEPH_MSG_OSD_OP, + sizeof(struct ceph_osd_request_head), 0, 0, 0); if (IS_ERR(req)) return req; memset(req->front.iov_base, 0, req->front.iov_len); @@ -172,17 +173,17 @@ struct ceph_msg *new_request_msg(struct ceph_osd_client *osdc, int op) head->op = cpu_to_le32(op); head->client_inst = osdc->client->msgr->inst; head->client_inc = 1; /* always, for now. */ - head->flags = 0; + head->flags = 0; return req; } -static struct ceph_osd_request *alloc_request(int nr_pages, +static struct ceph_osd_request *alloc_request(int nr_pages, struct ceph_msg *msg) { struct ceph_osd_request *req; - req = kmalloc(sizeof(*req) + nr_pages*sizeof(void*), GFP_KERNEL); + req = kmalloc(sizeof(*req) + nr_pages*sizeof(void *), GFP_KERNEL); if (req == NULL) return ERR_PTR(-ENOMEM); req->r_request = msg; @@ -204,10 +205,10 @@ static int register_request(struct ceph_osd_client *osdc, init_completion(&req->r_completion); dout(30, "register_request %p tid %lld\n", req, req->r_tid); - return radix_tree_insert(&osdc->request_tree, req->r_tid, (void*)req); + return radix_tree_insert(&osdc->request_tree, req->r_tid, (void *)req); } -static void send_request(struct ceph_osd_client *osdc, +static void send_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req) { int ruleno; @@ -217,29 +218,29 @@ static void send_request(struct ceph_osd_client *osdc, int pps; /* placement ps */ dout(30, "send_request %p\n", req); - - ruleno = crush_find_rule(osdc->osdmap->crush, req->r_pgid.pg.pool, + + ruleno = crush_find_rule(osdc->osdmap->crush, req->r_pgid.pg.pool, req->r_pgid.pg.type, req->r_pgid.pg.size); BUG_ON(ruleno < 0); /* fixme, need some proper error handling here */ dout(30, "using crush rule %d\n", ruleno); if (req->r_pgid.pg.preferred >= 0) - pps = ceph_stable_mod(req->r_pgid.pg.ps, - osdc->osdmap->lpgp_num, + pps = ceph_stable_mod(req->r_pgid.pg.ps, + osdc->osdmap->lpgp_num, osdc->osdmap->lpgp_num_mask); - else - pps = ceph_stable_mod(req->r_pgid.pg.ps, - osdc->osdmap->pgp_num, + else + pps = ceph_stable_mod(req->r_pgid.pg.ps, + osdc->osdmap->pgp_num, osdc->osdmap->pgp_num_mask); nr_osds = crush_do_rule(osdc->osdmap->crush, ruleno, pps, osds, req->r_pgid.pg.size, req->r_pgid.pg.preferred); - for (i=0; iosdmap, osds[i])) break; } if (i < nr_osds) { - dout(10, "send_request %p tid %llu to osd%d flags %d\n", + dout(10, "send_request %p tid %llu to osd%d flags %d\n", req, req->r_tid, osds[i], req->r_flags); - req->r_request->hdr.dst.name.type = + req->r_request->hdr.dst.name.type = cpu_to_le32(CEPH_ENTITY_TYPE_OSD); req->r_request->hdr.dst.name.num = cpu_to_le32(osds[i]); req->r_request->hdr.dst.addr = osdc->osdmap->osd_addr[osds[i]]; @@ -247,7 +248,7 @@ static void send_request(struct ceph_osd_client *osdc, ceph_msg_send(osdc->client->msgr, req->r_request, 0); } else { dout(10, "send_request no osds in this pg are up\n"); - ceph_monc_request_osdmap(&osdc->client->monc, + ceph_monc_request_osdmap(&osdc->client->monc, osdc->osdmap->epoch, 0); } } @@ -270,7 +271,7 @@ void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg) ceph_tid_t tid; dout(10, "handle_reply %p tid %llu\n", msg, le64_to_cpu(rhead->tid)); - + /* lookup */ tid = le64_to_cpu(rhead->tid); spin_lock(&osdc->lock); @@ -281,7 +282,7 @@ void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg) return; } get_request(req); - + if (req->r_reply == NULL) { dout(10, "handle_reply tid %llu saving reply\n", tid); ceph_msg_get(msg); @@ -323,7 +324,7 @@ int ceph_osdc_prepare_pages(void *p, struct ceph_msg *m, int want) dout(10, "prepare_pages unknown tid %llu\n", tid); goto out; } - dout(10, "prepare_pages tid %llu have %d pages, want %d\n", + dout(10, "prepare_pages tid %llu have %d pages, want %d\n", tid, req->r_nr_pages, want); if (likely(req->r_nr_pages >= want)) { m->pages = req->r_pages; @@ -353,7 +354,7 @@ int do_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req) reqhead->osdmap_epoch = osdc->osdmap->epoch; send_request(osdc, req); spin_unlock(&osdc->lock); - + rc = wait_for_completion_interruptible(&req->r_completion); spin_lock(&osdc->lock); @@ -365,8 +366,8 @@ int do_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req) replyhead = req->r_reply->front.iov_base; rc = le32_to_cpu(replyhead->result); bytes = le32_to_cpu(req->r_reply->hdr.data_len); - dout(10, "do_request tid %llu result %d, %d bytes\n", - req->r_tid, rc, bytes); + dout(10, "do_request tid %llu result %d, %d bytes\n", + req->r_tid, rc, bytes); } if (rc < 0) return rc; @@ -378,7 +379,7 @@ int do_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req) * request accordingly. shorten extent as necessary if it hits an * object boundary. */ -__u64 calc_layout(struct ceph_osd_client *osdc, +__u64 calc_layout(struct ceph_osd_client *osdc, ceph_ino_t ino, struct ceph_file_layout *layout, __u64 off, __u64 len, struct ceph_osd_request *req) @@ -391,17 +392,17 @@ __u64 calc_layout(struct ceph_osd_client *osdc, calc_file_object_mapping(layout, &toff, &tlen, &reqhead->oid, &off, &len); - if (tlen != 0) - dout(10, " skipping last %llu, writing %llu~%llu\n", + if (tlen != 0) + dout(10, " skipping last %llu, writing %llu~%llu\n", tlen, off, len); reqhead->offset = cpu_to_le64(off); reqhead->length = cpu_to_le64(len); - calc_object_layout(&reqhead->layout, &reqhead->oid, layout, + calc_object_layout(&reqhead->layout, &reqhead->oid, layout, osdc->osdmap); - dout(10, "calc_layout bno %u on %llu~%llu pgid %llx\n", - le32_to_cpu(reqhead->oid.bno), off, len, + dout(10, "calc_layout bno %u on %llu~%llu pgid %llx\n", + le32_to_cpu(reqhead->oid.bno), off, len, le64_to_cpu(reqhead->layout.ol_pgid)); return len; @@ -411,7 +412,7 @@ __u64 calc_layout(struct ceph_osd_client *osdc, * synchronous read direct to user buffer */ int ceph_osdc_sync_read(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, __u64 off, __u64 len, char __user *data) { @@ -437,7 +438,7 @@ int ceph_osdc_sync_read(struct ceph_osd_client *osdc, ceph_ino_t ino, dout(10, "sync_read %llu~%llu -> %d pages\n", off, len, nr_pages); /* allocate temp pages to hold data */ - for (i=0; ir_pages[i] = alloc_page(GFP_KERNEL); if (req->r_pages[i] == NULL) { req->r_nr_pages = i+1; @@ -469,7 +470,7 @@ int ceph_osdc_sync_read(struct ceph_osd_client *osdc, ceph_ino_t ino, } } put_request(req); - dout(10, "sync_read result %d\n", rc); + dout(10, "sync_read result %d\n", rc); return rc; } @@ -477,12 +478,12 @@ int ceph_osdc_sync_read(struct ceph_osd_client *osdc, ceph_ino_t ino, * read a single page. */ int ceph_osdc_readpage(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, loff_t off, loff_t len, struct page *page) { struct ceph_msg *reqm; - struct ceph_osd_request_head *reqhead; + struct ceph_osd_request_head *reqhead; struct ceph_osd_request *req; __s32 rc; @@ -503,22 +504,22 @@ int ceph_osdc_readpage(struct ceph_osd_client *osdc, ceph_ino_t ino, len = calc_layout(osdc, ino, layout, off, len, req); BUG_ON(len != PAGE_CACHE_SIZE); - + rc = do_request(osdc, req); put_request(req); - dout(10, "readpage result %d\n", rc); - if (rc == -ENOENT) + dout(10, "readpage result %d\n", rc); + if (rc == -ENOENT) rc = 0; /* object page dne; zero it */ return rc; } /* - * read some contiguous pages from page_list. + * read some contiguous pages from page_list. * - we stop if pages aren't contiguous, or when we hit an object boundary */ int ceph_osdc_readpages(struct ceph_osd_client *osdc, struct address_space *mapping, - ceph_ino_t ino, struct ceph_file_layout *layout, + ceph_ino_t ino, struct ceph_file_layout *layout, __u64 off, __u64 len, struct list_head *page_list, int nr_pages) { @@ -530,9 +531,9 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, __s32 rc; /* - * for now, our strategy is simple: start with the + * for now, our strategy is simple: start with the * initial page, and fetch as much of that object as - * we can that falls within the range specified by + * we can that falls within the range specified by * nr_pages. */ @@ -540,7 +541,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, /* alloc request, w/ page vector */ reqm = new_request_msg(osdc, CEPH_OSD_OP_READ); - if (IS_ERR(reqm)) + if (IS_ERR(reqm)) return PTR_ERR(reqm); req = alloc_request(nr_pages, reqm); if (req == 0) { @@ -567,14 +568,14 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, len = min((contig_pages << PAGE_CACHE_SHIFT) - (off & ~PAGE_CACHE_MASK), len); dout(10, "readpages contig page extent is %llu~%llu\n", off, len); - + /* request msg */ len = calc_layout(osdc, ino, layout, off, len, req); req->r_nr_pages = calc_pages_for(off, len); - dout(10, "readpages final extent is %llu~%llu -> %d pages\n", + dout(10, "readpages final extent is %llu~%llu -> %d pages\n", off, len, req->r_nr_pages); - + rc = do_request(osdc, req); put_request(req); dout(10, "readpages result %d\n", rc); @@ -586,7 +587,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc, * synchronous write. from userspace. */ int ceph_osdc_sync_write(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, __u64 off, __u64 len, const char __user *data) { struct ceph_msg *reqm; @@ -619,7 +620,7 @@ int ceph_osdc_sync_write(struct ceph_osd_client *osdc, ceph_ino_t ino, /* copy data into a set of pages */ left = len; po = off & ~PAGE_MASK; - for (i=0; ir_pages[i] = alloc_page(GFP_KERNEL); if (req->r_pages[i] == NULL) { req->r_nr_pages = i+1; @@ -641,7 +642,7 @@ int ceph_osdc_sync_write(struct ceph_osd_client *osdc, ceph_ino_t ino, put_request(req); if (rc == 0) rc = len; - dout(10, "sync_write result %d\n", rc); + dout(10, "sync_write result %d\n", rc); return rc; } @@ -649,7 +650,7 @@ int ceph_osdc_sync_write(struct ceph_osd_client *osdc, ceph_ino_t ino, * do a write job for N pages */ int ceph_osdc_writepages(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, loff_t off, loff_t len, struct page **pages, int nr_pages) { @@ -657,7 +658,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, ceph_ino_t ino, struct ceph_osd_request_head *reqhead; struct ceph_osd_request *req; int rc = 0; - + /* request + msg */ reqm = new_request_msg(osdc, CEPH_OSD_OP_WRITE); if (IS_ERR(reqm)) @@ -674,7 +675,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, ceph_ino_t ino, len = calc_layout(osdc, ino, layout, off, len, req); nr_pages = calc_pages_for(off, len); dout(10, "writepages %llu~%llu -> %d pages\n", off, len, nr_pages); - + /* copy pages */ memcpy(req->r_pages, pages, nr_pages * sizeof(struct page *)); reqm->pages = req->r_pages; diff --git a/src/kernel/osd_client.h b/src/kernel/osd_client.h index 48bb3294d3c8e..1769cdf600f7e 100644 --- a/src/kernel/osd_client.h +++ b/src/kernel/osd_client.h @@ -21,7 +21,7 @@ struct ceph_msg; /* - * pending request + * pending request */ enum { REQUEST_ACK, /* write serialized */ @@ -52,13 +52,16 @@ struct ceph_osd_client { struct completion map_waiters; }; -extern void ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client); -extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg); -extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg); +extern void ceph_osdc_init(struct ceph_osd_client *osdc, + struct ceph_client *client); +extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, + struct ceph_msg *msg); +extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, + struct ceph_msg *msg); extern int ceph_osdc_prepare_pages(void *p, struct ceph_msg *m, int want); extern int ceph_osdc_readpage(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, loff_t off, loff_t len, struct page *page); extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, @@ -67,39 +70,39 @@ extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, __u64 off, __u64 len, struct list_head *page_list, int nr_pages); extern int ceph_osdc_prepare_write(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, loff_t off, loff_t len, struct page *page); extern int ceph_osdc_commit_write(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, loff_t off, loff_t len, struct page *page); extern int ceph_osdc_writepages(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, + struct ceph_file_layout *layout, loff_t off, loff_t len, struct page **pagevec, int nr_pages); extern int ceph_osdc_sync_read(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, - __u64 off, __u64 len, + struct ceph_file_layout *layout, + __u64 off, __u64 len, char __user *data); extern int ceph_osdc_sync_write(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, - __u64 off, __u64 len, + struct ceph_file_layout *layout, + __u64 off, __u64 len, const char __user *data); extern int ceph_osdc_prepare_write(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, - loff_t off, loff_t len, - struct page *page); + struct ceph_file_layout *layout, + loff_t off, loff_t len, + struct page *page); extern int ceph_osdc_commit_write(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, - loff_t off, loff_t len, - struct page *page); + struct ceph_file_layout *layout, + loff_t off, loff_t len, + struct page *page); extern int ceph_osdc_writepage(struct ceph_osd_client *osdc, ceph_ino_t ino, - struct ceph_file_layout *layout, - loff_t off, loff_t len, - struct page *page); + struct ceph_file_layout *layout, + loff_t off, loff_t len, + struct page *page); #endif diff --git a/src/kernel/osdmap.c b/src/kernel/osdmap.c index c684eb22a0615..6ad0c7fe4ab08 100644 --- a/src/kernel/osdmap.c +++ b/src/kernel/osdmap.c @@ -13,7 +13,7 @@ int ceph_debug_osdmap = -1; /* maps */ -static int calc_bits_of(unsigned t) +static int calc_bits_of(unsigned t) { int b = 0; while (t) { @@ -31,7 +31,7 @@ static void calc_pg_masks(struct ceph_osdmap *map) map->lpgp_num_mask = (1 << calc_bits_of(map->lpgp_num-1)) - 1; } -static int crush_decode_uniform_bucket(void **p, void *end, +static int crush_decode_uniform_bucket(void **p, void *end, struct crush_bucket_uniform *b) { int j; @@ -40,7 +40,7 @@ static int crush_decode_uniform_bucket(void **p, void *end, if (b->primes == NULL) return -ENOMEM; ceph_decode_need(p, end, (1+b->h.size) * sizeof(__u32), bad); - for (j=0; jh.size; j++) + for (j = 0; j < b->h.size; j++) ceph_decode_32(p, b->primes[j]); ceph_decode_32(p, b->item_weight); return 0; @@ -60,7 +60,7 @@ static int crush_decode_list_bucket(void **p, void *end, if (b->sum_weights == NULL) return -ENOMEM; ceph_decode_need(p, end, 2 * b->h.size * sizeof(__u32), bad); - for (j=0; jh.size; j++) { + for (j = 0; j < b->h.size; j++) { ceph_decode_32(p, b->item_weights[j]); ceph_decode_32(p, b->sum_weights[j]); } @@ -69,7 +69,7 @@ bad: return -EINVAL; } -static int crush_decode_tree_bucket(void **p, void *end, +static int crush_decode_tree_bucket(void **p, void *end, struct crush_bucket_tree *b) { int j; @@ -78,14 +78,14 @@ static int crush_decode_tree_bucket(void **p, void *end, if (b->node_weights == NULL) return -ENOMEM; ceph_decode_need(p, end, b->h.size * sizeof(__u32), bad); - for (j=0; jh.size; j++) + for (j = 0; j < b->h.size; j++) ceph_decode_32(p, b->node_weights[j]); return 0; bad: return -EINVAL; } -static int crush_decode_straw_bucket(void **p, void *end, +static int crush_decode_straw_bucket(void **p, void *end, struct crush_bucket_straw *b) { int j; @@ -94,7 +94,7 @@ static int crush_decode_straw_bucket(void **p, void *end, if (b->straws == NULL) return -ENOMEM; ceph_decode_need(p, end, 2 * b->h.size * sizeof(__u32), bad); - for (j=0; jh.size; j++) { + for (j = 0; j < b->h.size; j++) { ceph_decode_32(p, b->item_weights[j]); ceph_decode_32(p, b->straws[j]); } @@ -122,34 +122,34 @@ static struct crush_map *crush_decode(void **p, void *end) ceph_decode_32(p, c->max_devices); c->device_offload = kmalloc(c->max_devices * sizeof(__u32), GFP_KERNEL); - if (c->device_offload == NULL) + if (c->device_offload == NULL) goto badmem; c->device_parents = kmalloc(c->max_devices * sizeof(__u32), GFP_KERNEL); - if (c->device_parents == NULL) + if (c->device_parents == NULL) goto badmem; c->bucket_parents = kmalloc(c->max_buckets * sizeof(__u32), GFP_KERNEL); - if (c->bucket_parents == NULL) + if (c->bucket_parents == NULL) goto badmem; c->buckets = kmalloc(c->max_buckets * sizeof(*c->buckets), GFP_KERNEL); - if (c->buckets == NULL) + if (c->buckets == NULL) goto badmem; c->rules = kmalloc(c->max_rules * sizeof(*c->rules), GFP_KERNEL); if (c->rules == NULL) goto badmem; ceph_decode_need(p, end, c->max_devices * sizeof(__u32), bad); - for (i=0; imax_devices; i++) + for (i = 0; i < c->max_devices; i++) ceph_decode_32(p, c->device_offload[i]); - + /* buckets */ - for (i=0; imax_buckets; i++) { + for (i = 0; i < c->max_buckets; i++) { int size = 0; __u32 type; struct crush_bucket *b; dout(30, "crush_decode bucket %d off %x %p to %p\n", - i, (int)(*p-start), *p, end); + i, (int)(*p-start), *p, end); ceph_decode_32_safe(p, end, type, bad); if (type == 0) { @@ -183,7 +183,7 @@ static struct crush_map *crush_decode(void **p, void *end) ceph_decode_32(p, b->weight); ceph_decode_32(p, b->size); - dout(30, "crush_decode bucket size %d off %x %p to %p\n", + dout(30, "crush_decode bucket size %d off %x %p to %p\n", b->size, (int)(*p-start), *p, end); b->items = kmalloc(b->size * sizeof(__s32), GFP_KERNEL); @@ -191,39 +191,43 @@ static struct crush_map *crush_decode(void **p, void *end) goto badmem; ceph_decode_need(p, end, b->size*sizeof(__u32), bad); - for (j=0; jsize; j++) + for (j = 0; j < b->size; j++) ceph_decode_32(p, b->items[j]); - + switch (b->type) { case CRUSH_BUCKET_UNIFORM: - if ((err = crush_decode_uniform_bucket(p, end, - (struct crush_bucket_uniform*)b)) < 0) + err = crush_decode_uniform_bucket(p, end, + (struct crush_bucket_uniform *)b); + if (err < 0) goto bad; break; case CRUSH_BUCKET_LIST: - if ((err = crush_decode_list_bucket(p, end, - (struct crush_bucket_list*)b)) < 0) + err = crush_decode_list_bucket(p, end, + (struct crush_bucket_list *)b); + if (err < 0) goto bad; break; case CRUSH_BUCKET_TREE: - if ((err = crush_decode_tree_bucket(p, end, - (struct crush_bucket_tree*)b)) < 0) + err = crush_decode_tree_bucket(p, end, + (struct crush_bucket_tree *)b); + if (err < 0) goto bad; break; case CRUSH_BUCKET_STRAW: - if ((err = crush_decode_straw_bucket(p, end, - (struct crush_bucket_straw*)b)) < 0) + err = crush_decode_straw_bucket(p, end, + (struct crush_bucket_straw *)b); + if (err < 0) goto bad; break; } } /* rules */ - for (i=0; imax_rules; i++) { + for (i = 0; i < c->max_rules; i++) { __u32 yes; struct crush_rule *r; - dout(30, "crush_decode rule %d off %x %p to %p\n", + dout(30, "crush_decode rule %d off %x %p to %p\n", i, (int)(*p-start), *p, end); ceph_decode_32_safe(p, end, yes, bad); @@ -232,7 +236,7 @@ static struct crush_map *crush_decode(void **p, void *end) continue; } - // len + /* len */ ceph_decode_32_safe(p, end, yes, bad); r = c->rules[i] = kmalloc(sizeof(**c->rules) + @@ -243,7 +247,7 @@ static struct crush_map *crush_decode(void **p, void *end) r->len = yes; ceph_decode_copy_safe(p, end, &r->mask, 4, bad); /* 4 u8's */ ceph_decode_need(p, end, r->len*3*sizeof(__u32), bad); - for (j=0; jlen; j++) { + for (j = 0; j < r->len; j++) { ceph_decode_32(p, r->steps[j].op); ceph_decode_32(p, r->steps[j].arg1); ceph_decode_32(p, r->steps[j].arg2); @@ -251,10 +255,10 @@ static struct crush_map *crush_decode(void **p, void *end) } /* ignore trailing name maps */ - + dout(30, "crush_decode success\n"); return c; - + badmem: err = -ENOMEM; bad: @@ -265,8 +269,8 @@ bad: void osdmap_destroy(struct ceph_osdmap *map) { - if (map->osd_state) kfree(map->osd_state); - if (map->crush) kfree(map->crush); + kfree(map->osd_state); + kfree(map->crush); kfree(map); } @@ -275,12 +279,12 @@ static int osdmap_set_max_osd(struct ceph_osdmap *map, int max) __u8 *state; struct ceph_entity_addr *addr; - state = kzalloc(max * (sizeof(__u32) + + state = kzalloc(max * (sizeof(__u32) + sizeof(struct ceph_entity_addr)), GFP_KERNEL); - if (state == NULL) + if (state == NULL) return -ENOMEM; - addr = (void*)((__u32*)state + max); + addr = (void *)((__u32 *)state + max); /* copy old? */ if (map->osd_state) { @@ -306,7 +310,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end) dout(30, "osdmap_decode from %p to %p\n", *p, end); map = kzalloc(sizeof(*map), GFP_KERNEL); - if (map == NULL) + if (map == NULL) return ERR_PTR(-ENOMEM); ceph_decode_need(p, end, 2*sizeof(__u64)+9*sizeof(__u32), bad); @@ -328,13 +332,14 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end) ceph_decode_32(p, max); /* (re)alloc osd arrays */ - if ((err = osdmap_set_max_osd(map, max)) < 0) + err = osdmap_set_max_osd(map, max); + if (err < 0) goto bad; dout(30, "osdmap_decode max_osd = %d\n", map->max_osd); - + /* osds */ err = -EINVAL; - ceph_decode_need(p, end, 2*sizeof(__u32) + + ceph_decode_need(p, end, 2*sizeof(__u32) + map->max_osd*(1+sizeof(*map->osd_addr)), bad); *p += 4; /* skip length field (should match max) */ ceph_decode_copy(p, map->osd_state, map->max_osd); @@ -344,14 +349,14 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end) /* pg primary swapping */ ceph_decode_32_safe(p, end, len, bad); if (len) { - map->pg_swap_primary = kmalloc(len * - sizeof(*map->pg_swap_primary), + map->pg_swap_primary = kmalloc(len * + sizeof(*map->pg_swap_primary), GFP_KERNEL); - if (map->pg_swap_primary == NULL) + if (map->pg_swap_primary == NULL) goto badmem; map->num_pg_swap_primary = len; ceph_decode_need(p, end, sizeof(__u64)+sizeof(__u32), bad); - for (i=0; ipg_swap_primary[i].pg.pg64); ceph_decode_32(p, map->pg_swap_primary[i].osd); } @@ -359,7 +364,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end) /* crush */ ceph_decode_32_safe(p, end, len, bad); - dout(30, "osdmap_decode crush len %d from off %x\n", + dout(30, "osdmap_decode crush len %d from off %x\n", len, (int)(*p - start)); map->crush = crush_decode(p, end); if (IS_ERR(map->crush)) { @@ -423,7 +428,7 @@ struct ceph_osdmap *apply_incremental(void **p, void *end, /* * FIXME: from this point on i'm optimisticaly assuming the message - * is complete + * is complete */ /* new max? */ @@ -431,14 +436,15 @@ struct ceph_osdmap *apply_incremental(void **p, void *end, ceph_decode_32(p, max); *p += 4*sizeof(__u32); /* skip new_pg_num et al for now. FIXME. */ if (max >= 0) { - if ((err = osdmap_set_max_osd(map, max)) < 0) + err = osdmap_set_max_osd(map, max); + if (err < 0) goto bad; } map->epoch++; map->ctime = map->ctime; if (newcrush) { - if (map->crush) + if (map->crush) crush_destroy(map->crush); map->crush = newcrush; } @@ -463,7 +469,7 @@ struct ceph_osdmap *apply_incremental(void **p, void *end, __u32 osd; ceph_decode_32_safe(p, end, osd, bad); dout(1, "osd%d down\n", osd); - if (osd < map->max_osd) + if (osd < map->max_osd) map->osd_state[osd] &= ~CEPH_OSD_UP; } @@ -475,7 +481,7 @@ struct ceph_osdmap *apply_incremental(void **p, void *end, ceph_decode_32(p, osd); ceph_decode_32(p, off); dout(1, "osd%d offload %x\n", osd, off); - if (osd < map->max_osd) + if (osd < map->max_osd) map->crush->device_offload[osd] = off; } @@ -500,7 +506,7 @@ bad: * update file offset,length to end of extent, or * the next file extent not included in current mapping. */ -void calc_file_object_mapping(struct ceph_file_layout *layout, +void calc_file_object_mapping(struct ceph_file_layout *layout, loff_t *off, loff_t *len, struct ceph_object *oid, __u64 *oxoff, __u64 *oxlen) @@ -533,20 +539,20 @@ void calc_file_object_mapping(struct ceph_file_layout *layout, *oxoff = do_div(t, layout->fl_stripe_unit); first_oxlen = min_t(loff_t, *len, layout->fl_stripe_unit); *oxlen = first_oxlen; - + /* multiple stripe units across this object? */ t = *len; while (t > stripe_len && *oxoff + *oxlen < layout->fl_object_size) { *oxlen += min_t(loff_t, layout->fl_stripe_unit, t); t -= stripe_len; } - + *off += first_oxlen; *len -= *oxlen; } /* - * calculate an object layout (i.e. pgid) from an oid, + * calculate an object layout (i.e. pgid) from an oid, * file_layout, and osdmap */ void calc_object_layout(struct ceph_object_layout *ol, @@ -568,7 +574,7 @@ void calc_object_layout(struct ceph_object_layout *ol, } pgid.pg64 = 0; /* start with it zeroed out */ - pgid.pg.ps = ceph_stable_mod(bno + crush_hash32_2(ino, ino>>32), + pgid.pg.ps = ceph_stable_mod(bno + crush_hash32_2(ino, ino>>32), num, num_mask); pgid.pg.preferred = fl->fl_pg_preferred; pgid.pg.type = fl->fl_pg_type; diff --git a/src/kernel/osdmap.h b/src/kernel/osdmap.h index 987503f279553..f7e8d62dc7615 100644 --- a/src/kernel/osdmap.h +++ b/src/kernel/osdmap.h @@ -10,13 +10,13 @@ struct ceph_osdmap { ceph_epoch_t epoch; ceph_epoch_t mkfs_epoch; struct ceph_timespec ctime, mtime; - + __u32 pg_num, pg_num_mask; __u32 pgp_num, pgp_num_mask; __u32 lpg_num, lpg_num_mask; __u32 lpgp_num, lpgp_num_mask; ceph_epoch_t last_pg_change; - + __u32 max_osd; __u8 *osd_state; __u32 *osd_offload; /* 0 = normal, 0x10000 = 100% offload (failed) */ @@ -35,13 +35,15 @@ static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd) return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP); } -extern struct ceph_osdmap *apply_incremental(void **p, void *end, struct ceph_osdmap *map); +extern struct ceph_osdmap *apply_incremental(void **p, void *end, + struct ceph_osdmap *map); extern void osdmap_destroy(struct ceph_osdmap *map); extern struct ceph_osdmap *osdmap_decode(void **p, void *end); -extern void calc_file_object_mapping(struct ceph_file_layout *layout, +extern void calc_file_object_mapping(struct ceph_file_layout *layout, loff_t *off, loff_t *len, - struct ceph_object *oid, __u64 *oxoff, __u64 *oxlen); + struct ceph_object *oid, + __u64 *oxoff, __u64 *oxlen); extern void calc_object_layout(struct ceph_object_layout *ol, struct ceph_object *oid, struct ceph_file_layout *fl, diff --git a/src/kernel/proc.c b/src/kernel/proc.c index c93413497a79a..038a798d403e6 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -68,13 +68,13 @@ void ceph_fs_proc_init(void) return; proc_fs_ceph->owner = THIS_MODULE; - pde = create_proc_read_entry("debug", 0, - proc_fs_ceph, ceph_debug_level_read, + pde = create_proc_read_entry("debug", 0, + proc_fs_ceph, ceph_debug_level_read, &ceph_debug); if (pde) pde->write_proc = ceph_debug_level_write; - pde = create_proc_read_entry("debug_msgr", 0, - proc_fs_ceph, ceph_debug_level_read, + pde = create_proc_read_entry("debug_msgr", 0, + proc_fs_ceph, ceph_debug_level_read, &ceph_debug_msgr); if (pde) pde->write_proc = ceph_debug_level_write; diff --git a/src/kernel/super.c b/src/kernel/super.c index 5e2fd01fb0851..b06906a889aaa 100644 --- a/src/kernel/super.c +++ b/src/kernel/super.c @@ -9,8 +9,8 @@ /* debug levels; defined in super.h */ /* - * global debug value. - * 0 = quiet. + * global debug value. + * 0 = quiet. * * if the per-file debug level >= 0, then that overrides this global * debug level. @@ -169,11 +169,7 @@ static void ceph_destroy_inode(struct inode *inode) kmem_cache_free(ceph_inode_cachep, ci); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) -static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags) -#else static void init_once(struct kmem_cache *cachep, void *foo) -#endif { struct ceph_inode_info *ci = foo; dout(10, "init_once on %p\n", foo); @@ -182,20 +178,11 @@ static void init_once(struct kmem_cache *cachep, void *foo) static int init_inodecache(void) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23) ceph_inode_cachep = kmem_cache_create("ceph_inode_cache", sizeof(struct ceph_inode_info), 0, (SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), init_once); -#else - ceph_inode_cachep = kmem_cache_create("ceph_inode_cache", - sizeof(struct ceph_inode_info), - 0, (SLAB_RECLAIM_ACCOUNT| - SLAB_MEM_SPREAD), - init_once, - NULL); -#endif if (ceph_inode_cachep == NULL) return -ENOMEM; return 0; @@ -210,7 +197,7 @@ static const struct super_operations ceph_sops = { .alloc_inode = ceph_alloc_inode, .destroy_inode = ceph_destroy_inode, .write_inode = ceph_write_inode, - .sync_fs = ceph_syncfs, + .sync_fs = ceph_syncfs, .put_super = ceph_put_super, .show_options = ceph_show_options, .statfs = ceph_statfs, @@ -284,7 +271,7 @@ static int parse_ip(const char *c, int len, struct ceph_entity_addr *addr) goto bad; *(__be32 *)&addr->ipaddr.sin_addr.s_addr = htonl(ip); - dout(15, "parse_ip got %u.%u.%u.%u\n", + dout(15, "parse_ip got %u.%u.%u.%u\n", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); return 0; @@ -343,7 +330,7 @@ static int parse_mount_args(int flags, char *options, const char *dev_name, if (token < 0) { derr(0, "bad mount option at '%s'\n", c); return -EINVAL; - + } if (token < Opt_ip) { ret = match_int(&argstr[0], &intval); @@ -377,7 +364,7 @@ static int parse_mount_args(int flags, char *options, const char *dev_name, return err; args->flags |= CEPH_MOUNT_MYIP; break; - + /* debug levels */ case Opt_debug: ceph_debug = intval; @@ -551,6 +538,8 @@ static int __init init_ceph(void) dout(1, "init_ceph\n"); + spin_lock_init(&ceph_client_spinlock); + ceph_fs_proc_init(); ret = init_inodecache(); diff --git a/src/kernel/super.h b/src/kernel/super.h index 8de815f57db83..37e175ca495aa 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -85,7 +85,7 @@ struct ceph_client { unsigned long mounting; /* map bitset; 4=mon, 2=mds, 1=osd map */ wait_queue_head_t mount_wq; - + struct ceph_messenger *msgr; /* messenger instance */ struct ceph_mon_client monc; struct ceph_mds_client mdsc; @@ -192,7 +192,7 @@ static inline struct ceph_dentry_info *ceph_dentry(struct dentry *dentry) return (struct ceph_dentry_info *)dentry->d_fsdata; } -static inline void ceph_queue_writeback(struct ceph_client *cl, +static inline void ceph_queue_writeback(struct ceph_client *cl, struct ceph_inode_info *ci) { queue_work(cl->wb_wq, &ci->i_wb_work); @@ -283,7 +283,7 @@ static inline int __ceph_caps_wanted(struct ceph_inode_info *ci) return w; } -static inline void __ceph_get_fmode(struct ceph_inode_info *ci, int mode) +static inline void __ceph_get_fmode(struct ceph_inode_info *ci, int mode) { ci->i_nr_by_mode[mode]++; } @@ -314,7 +314,7 @@ struct ceph_file_info { */ static inline int calc_pages_for(int off, int len) { - return ((off+len+PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT) - + return ((off+len+PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT) - (off >> PAGE_CACHE_SHIFT); /* int nr = 0; @@ -330,11 +330,14 @@ static inline int calc_pages_for(int off, int len) /* client.c */ +extern spinlock_t ceph_client_spinlock; +extern int ceph_num_clients; + extern struct ceph_client *ceph_create_client(struct ceph_mount_args *args, struct super_block *sb); extern void ceph_destroy_client(struct ceph_client *cl); -extern int ceph_mount(struct ceph_client *client, - struct ceph_mount_args *args, +extern int ceph_mount(struct ceph_client *client, + struct ceph_mount_args *args, struct vfsmount *mnt); extern void ceph_umount_start(struct ceph_client *cl); extern const char *ceph_msg_type_name(int type); @@ -344,16 +347,16 @@ extern const char *ceph_msg_type_name(int type); extern struct inode *ceph_get_inode(struct super_block *sb, u64 ino); extern int ceph_fill_inode(struct inode *inode, struct ceph_mds_reply_inode *info); -extern int ceph_fill_trace(struct super_block *sb, +extern int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, struct ceph_mds_session *session); extern int ceph_readdir_prepopulate(struct ceph_mds_request *req); -extern void ceph_update_inode_lease(struct inode *inode, +extern void ceph_update_inode_lease(struct inode *inode, struct ceph_mds_reply_lease *lease, struct ceph_mds_session *seesion, unsigned long from_time); -extern void ceph_update_dentry_lease(struct dentry *dentry, +extern void ceph_update_dentry_lease(struct dentry *dentry, struct ceph_mds_reply_lease *lease, struct ceph_mds_session *session, unsigned long from_time); -- 2.39.5