Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373457
b: refs/heads/master
c: 26be880
h: refs/heads/master
i:
  373455: f9e04ed
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent cd01153 commit 0153b07
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7d7d51ce14fde491a6d0677d9bded9b3bd0d21d9
refs/heads/master: 26be88087ae8a04a5b576aa2f490597b649fc132
52 changes: 28 additions & 24 deletions trunk/fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,19 +446,35 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data,
}

/*
* Write commit callback, called if we requested both an ACK and
* ONDISK commit reply from the OSD.
* Write commit request unsafe callback, called to tell us when a
* request is unsafe (that is, in flight--has been handed to the
* messenger to send to its target osd). It is called again when
* we've received a response message indicating the request is
* "safe" (its CEPH_OSD_FLAG_ONDISK flag is set), or when a request
* is completed early (and unsuccessfully) due to a timeout or
* interrupt.
*
* This is used if we requested both an ACK and ONDISK commit reply
* from the OSD.
*/
static void sync_write_commit(struct ceph_osd_request *req,
struct ceph_msg *msg)
static void ceph_sync_write_unsafe(struct ceph_osd_request *req, bool unsafe)
{
struct ceph_inode_info *ci = ceph_inode(req->r_inode);

dout("sync_write_commit %p tid %llu\n", req, req->r_tid);
spin_lock(&ci->i_unsafe_lock);
list_del_init(&req->r_unsafe_item);
spin_unlock(&ci->i_unsafe_lock);
ceph_put_cap_refs(ci, CEPH_CAP_FILE_WR);
dout("%s %p tid %llu %ssafe\n", __func__, req, req->r_tid,
unsafe ? "un" : "");
if (unsafe) {
ceph_get_cap_refs(ci, CEPH_CAP_FILE_WR);
spin_lock(&ci->i_unsafe_lock);
list_add_tail(&req->r_unsafe_item,
&ci->i_unsafe_writes);
spin_unlock(&ci->i_unsafe_lock);
} else {
spin_lock(&ci->i_unsafe_lock);
list_del_init(&req->r_unsafe_item);
spin_unlock(&ci->i_unsafe_lock);
ceph_put_cap_refs(ci, CEPH_CAP_FILE_WR);
}
}

/*
Expand Down Expand Up @@ -570,7 +586,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,

if ((file->f_flags & O_SYNC) == 0) {
/* get a second commit callback */
req->r_safe_callback = sync_write_commit;
req->r_unsafe_callback = ceph_sync_write_unsafe;
req->r_inode = inode;
own_pages = true;
}
}
Expand All @@ -581,21 +598,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
ceph_osdc_build_request(req, pos, snapc, vino.snap, &mtime);

ret = ceph_osdc_start_request(&fsc->client->osdc, req, false);
if (!ret) {
if (req->r_safe_callback) {
/*
* Add to inode unsafe list only after we
* start_request so that a tid has been assigned.
*/
spin_lock(&ci->i_unsafe_lock);
list_add_tail(&req->r_unsafe_item,
&ci->i_unsafe_writes);
spin_unlock(&ci->i_unsafe_lock);
ceph_get_cap_refs(ci, CEPH_CAP_FILE_WR);
}

if (!ret)
ret = ceph_osdc_wait_request(&fsc->client->osdc, req);
}

if (file->f_flags & O_DIRECT)
ceph_put_page_vector(pages, num_pages, false);
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/ceph/osd_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct ceph_authorizer;
*/
typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *,
struct ceph_msg *);
typedef void (*ceph_osdc_unsafe_callback_t)(struct ceph_osd_request *, bool);

/* a given osd we're communicating with */
struct ceph_osd {
Expand Down Expand Up @@ -149,7 +150,8 @@ struct ceph_osd_request {
struct kref r_kref;
bool r_mempool;
struct completion r_completion, r_safe_completion;
ceph_osdc_callback_t r_callback, r_safe_callback;
ceph_osdc_callback_t r_callback;
ceph_osdc_unsafe_callback_t r_unsafe_callback;
struct ceph_eversion r_reassert_version;
struct list_head r_unsafe_item;

Expand Down
12 changes: 9 additions & 3 deletions trunk/net/ceph/osd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,14 @@ static void __send_request(struct ceph_osd_client *osdc,
list_move_tail(&req->r_req_lru_item, &osdc->req_lru);

ceph_msg_get(req->r_request); /* send consumes a ref */
ceph_con_send(&req->r_osd->o_con, req->r_request);

/* Mark the request unsafe if this is the first timet's being sent. */

if (!req->r_sent && req->r_unsafe_callback)
req->r_unsafe_callback(req, true);
req->r_sent = req->r_osd->o_incarnation;

ceph_con_send(&req->r_osd->o_con, req->r_request);
}

/*
Expand Down Expand Up @@ -1403,8 +1409,8 @@ static void handle_osds_timeout(struct work_struct *work)

static void complete_request(struct ceph_osd_request *req)
{
if (req->r_safe_callback)
req->r_safe_callback(req, NULL);
if (req->r_unsafe_callback)
req->r_unsafe_callback(req, false);
complete_all(&req->r_safe_completion); /* fsync waiter */
}

Expand Down

0 comments on commit 0153b07

Please sign in to comment.