* [PATCH 0/3] libceph: a few miscellaneous cleanups
@ 2013-02-16 16:33 Alex Elder
2013-02-16 16:34 ` [PATCH 1/3] libceph: lock outside send_queued() Alex Elder
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alex Elder @ 2013-02-16 16:33 UTC (permalink / raw)
To: ceph-devel
These changes aren't all that closely related, but they all
are cleanups in the osd client.
-Alex
[PATCH 1/3] libceph: lock outside send_queued()
[PATCH 2/3] libdeph: don't export ceph_osdc_init() or ceph_osdc_stop()
[PATCH 3/3] libceph: kill ceph_calc_raw_layout()
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] libceph: lock outside send_queued()
2013-02-16 16:33 [PATCH 0/3] libceph: a few miscellaneous cleanups Alex Elder
@ 2013-02-16 16:34 ` Alex Elder
2013-02-16 16:34 ` [PATCH 2/3] libdeph: don't export ceph_osdc_init() or ceph_osdc_stop() Alex Elder
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2013-02-16 16:34 UTC (permalink / raw)
To: ceph-devel
Two of the three callers of the osd client's send_queued() function
already hold the osd client mutex and drop it before the call.
Change send_queued() so it assumes the caller holds the mutex, and
update all callers accordingly. Rename it __send_queued() to match
the convention used elsewhere in the file with respect to the lock.
Signed-off-by: Alex Elder <elder@inktank.com>
---
net/ceph/osd_client.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d3e7513..edda070 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -23,7 +23,7 @@
static const struct ceph_connection_operations osd_con_ops;
-static void send_queued(struct ceph_osd_client *osdc);
+static void __send_queued(struct ceph_osd_client *osdc);
static int __reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd);
static void __register_request(struct ceph_osd_client *osdc,
struct ceph_osd_request *req);
@@ -554,8 +554,8 @@ static void osd_reset(struct ceph_connection *con)
down_read(&osdc->map_sem);
mutex_lock(&osdc->request_mutex);
__kick_osd_requests(osdc, osd);
+ __send_queued(osdc);
mutex_unlock(&osdc->request_mutex);
- send_queued(osdc);
up_read(&osdc->map_sem);
}
@@ -997,16 +997,13 @@ static void __send_request(struct ceph_osd_client
*osdc,
/*
* Send any requests in the queue (req_unsent).
*/
-static void send_queued(struct ceph_osd_client *osdc)
+static void __send_queued(struct ceph_osd_client *osdc)
{
struct ceph_osd_request *req, *tmp;
- dout("send_queued\n");
- mutex_lock(&osdc->request_mutex);
- list_for_each_entry_safe(req, tmp, &osdc->req_unsent, r_req_lru_item) {
+ dout("__send_queued\n");
+ list_for_each_entry_safe(req, tmp, &osdc->req_unsent, r_req_lru_item)
__send_request(osdc, req);
- }
- mutex_unlock(&osdc->request_mutex);
}
/*
@@ -1058,8 +1055,8 @@ static void handle_timeout(struct work_struct *work)
}
__schedule_osd_timeout(osdc);
+ __send_queued(osdc);
mutex_unlock(&osdc->request_mutex);
- send_queued(osdc);
up_read(&osdc->map_sem);
}
@@ -1397,7 +1394,9 @@ done:
if (ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_FULL))
ceph_monc_request_next_osdmap(&osdc->client->monc);
- send_queued(osdc);
+ mutex_lock(&osdc->request_mutex);
+ __send_queued(osdc);
+ mutex_unlock(&osdc->request_mutex);
up_read(&osdc->map_sem);
wake_up_all(&osdc->client->auth_wq);
return;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] libdeph: don't export ceph_osdc_init() or ceph_osdc_stop()
2013-02-16 16:33 [PATCH 0/3] libceph: a few miscellaneous cleanups Alex Elder
2013-02-16 16:34 ` [PATCH 1/3] libceph: lock outside send_queued() Alex Elder
@ 2013-02-16 16:34 ` Alex Elder
2013-02-16 16:34 ` [PATCH 3/3] libceph: kill ceph_calc_raw_layout() Alex Elder
2013-02-16 23:40 ` [PATCH 0/3] libceph: a few miscellaneous cleanups Josh Durgin
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2013-02-16 16:34 UTC (permalink / raw)
To: ceph-devel
The only callers of ceph_osdc_init() and ceph_osdc_stop()
ceph_create_client() and ceph_destroy_client() (respectively)
and they are in the same kernel module as those two functions.
There's therefore no need to export those interfaces, so don't.
Signed-off-by: Alex Elder <elder@inktank.com>
---
net/ceph/osd_client.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index edda070..0d67cd3 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1799,7 +1799,6 @@ out_mempool:
out:
return err;
}
-EXPORT_SYMBOL(ceph_osdc_init);
void ceph_osdc_stop(struct ceph_osd_client *osdc)
{
@@ -1816,7 +1815,6 @@ void ceph_osdc_stop(struct ceph_osd_client *osdc)
ceph_msgpool_destroy(&osdc->msgpool_op);
ceph_msgpool_destroy(&osdc->msgpool_op_reply);
}
-EXPORT_SYMBOL(ceph_osdc_stop);
/*
* Read some contiguous pages. If we cross a stripe boundary, shorten
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] libceph: kill ceph_calc_raw_layout()
2013-02-16 16:33 [PATCH 0/3] libceph: a few miscellaneous cleanups Alex Elder
2013-02-16 16:34 ` [PATCH 1/3] libceph: lock outside send_queued() Alex Elder
2013-02-16 16:34 ` [PATCH 2/3] libdeph: don't export ceph_osdc_init() or ceph_osdc_stop() Alex Elder
@ 2013-02-16 16:34 ` Alex Elder
2013-02-16 23:40 ` [PATCH 0/3] libceph: a few miscellaneous cleanups Josh Durgin
3 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2013-02-16 16:34 UTC (permalink / raw)
To: ceph-devel
There is no caller of ceph_calc_raw_layout() outside of libceph, so
there's no need to export from the module.
Furthermore, there is only one caller, in calc_layout(), and it
is not much more than a simple wrapper for that function.
So get rid of ceph_calc_raw_layout() and embed it instead within
calc_layout().
While touching "osd_client.c", get rid of the unnecessary forward
declaration of __send_request().
Signed-off-by: Alex Elder <elder@inktank.com>
---
include/linux/ceph/osd_client.h | 5 ---
net/ceph/osd_client.c | 77
++++++++++++++++-----------------------
2 files changed, 32 insertions(+), 50 deletions(-)
diff --git a/include/linux/ceph/osd_client.h
b/include/linux/ceph/osd_client.h
index 5812802..c39e7ed 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -207,11 +207,6 @@ extern void ceph_osdc_handle_reply(struct
ceph_osd_client *osdc,
extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
struct ceph_msg *msg);
-extern int ceph_calc_raw_layout(struct ceph_file_layout *layout,
- u64 off, u64 *plen, u64 *bno,
- struct ceph_osd_request *req,
- struct ceph_osd_req_op *op);
-
extern struct ceph_osd_request *ceph_osdc_alloc_request(struct
ceph_osd_client *osdc,
struct ceph_snap_context *snapc,
unsigned int num_op,
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 0d67cd3..cd3a489 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -38,49 +38,6 @@ static int op_has_extent(int op)
op == CEPH_OSD_OP_WRITE);
}
-int ceph_calc_raw_layout(struct ceph_file_layout *layout,
- u64 off, u64 *plen, u64 *bno,
- struct ceph_osd_request *req,
- struct ceph_osd_req_op *op)
-{
- u64 orig_len = *plen;
- u64 objoff, objlen; /* extent in object */
- int r;
-
- /* object extent? */
- r = ceph_calc_file_object_mapping(layout, off, orig_len, bno,
- &objoff, &objlen);
- if (r < 0)
- return r;
- if (objlen < orig_len) {
- *plen = objlen;
- dout(" skipping last %llu, final file extent %llu~%llu\n",
- orig_len - *plen, off, *plen);
- }
-
- if (op_has_extent(op->op)) {
- u32 osize = le32_to_cpu(layout->fl_object_size);
- op->extent.offset = objoff;
- op->extent.length = objlen;
- if (op->extent.truncate_size <= off - objoff) {
- op->extent.truncate_size = 0;
- } else {
- op->extent.truncate_size -= off - objoff;
- if (op->extent.truncate_size > osize)
- op->extent.truncate_size = osize;
- }
- }
- req->r_num_pages = calc_pages_for(off, *plen);
- req->r_page_alignment = off & ~PAGE_MASK;
- if (op->op == CEPH_OSD_OP_WRITE)
- op->payload_len = *plen;
-
- dout("calc_layout bno=%llx %llu~%llu (%d pages)\n",
- *bno, objoff, objlen, req->r_num_pages);
- return 0;
-}
-EXPORT_SYMBOL(ceph_calc_raw_layout);
-
/*
* Implement client access to distributed object storage cluster.
*
@@ -112,12 +69,42 @@ static int calc_layout(struct ceph_vino vino,
struct ceph_osd_request *req,
struct ceph_osd_req_op *op)
{
- u64 bno;
+ u64 orig_len = *plen;
+ u64 bno = 0;
+ u64 objoff = 0;
+ u64 objlen = 0;
int r;
- r = ceph_calc_raw_layout(layout, off, plen, &bno, req, op);
+ /* object extent? */
+ r = ceph_calc_file_object_mapping(layout, off, orig_len, &bno,
+ &objoff, &objlen);
if (r < 0)
return r;
+ if (objlen < orig_len) {
+ *plen = objlen;
+ dout(" skipping last %llu, final file extent %llu~%llu\n",
+ orig_len - *plen, off, *plen);
+ }
+
+ if (op_has_extent(op->op)) {
+ u32 osize = le32_to_cpu(layout->fl_object_size);
+ op->extent.offset = objoff;
+ op->extent.length = objlen;
+ if (op->extent.truncate_size <= off - objoff) {
+ op->extent.truncate_size = 0;
+ } else {
+ op->extent.truncate_size -= off - objoff;
+ if (op->extent.truncate_size > osize)
+ op->extent.truncate_size = osize;
+ }
+ }
+ req->r_num_pages = calc_pages_for(off, *plen);
+ req->r_page_alignment = off & ~PAGE_MASK;
+ if (op->op == CEPH_OSD_OP_WRITE)
+ op->payload_len = *plen;
+
+ dout("calc_layout bno=%llx %llu~%llu (%d pages)\n",
+ bno, objoff, objlen, req->r_num_pages);
snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", vino.ino, bno);
req->r_oid_len = strlen(req->r_oid);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] libceph: a few miscellaneous cleanups
2013-02-16 16:33 [PATCH 0/3] libceph: a few miscellaneous cleanups Alex Elder
` (2 preceding siblings ...)
2013-02-16 16:34 ` [PATCH 3/3] libceph: kill ceph_calc_raw_layout() Alex Elder
@ 2013-02-16 23:40 ` Josh Durgin
3 siblings, 0 replies; 5+ messages in thread
From: Josh Durgin @ 2013-02-16 23:40 UTC (permalink / raw)
To: Alex Elder; +Cc: ceph-devel
On 02/16/2013 08:33 AM, Alex Elder wrote:
> These changes aren't all that closely related, but they all
> are cleanups in the osd client.
>
> -Alex
>
> [PATCH 1/3] libceph: lock outside send_queued()
> [PATCH 2/3] libdeph: don't export ceph_osdc_init() or ceph_osdc_stop()
> [PATCH 3/3] libceph: kill ceph_calc_raw_layout()
These look good.
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-16 23:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-16 16:33 [PATCH 0/3] libceph: a few miscellaneous cleanups Alex Elder
2013-02-16 16:34 ` [PATCH 1/3] libceph: lock outside send_queued() Alex Elder
2013-02-16 16:34 ` [PATCH 2/3] libdeph: don't export ceph_osdc_init() or ceph_osdc_stop() Alex Elder
2013-02-16 16:34 ` [PATCH 3/3] libceph: kill ceph_calc_raw_layout() Alex Elder
2013-02-16 23:40 ` [PATCH 0/3] libceph: a few miscellaneous cleanups Josh Durgin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.