Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/sage/ceph-client

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
  ceph: keep reference to parent inode on ceph_dentry
  ceph: queue cap_snaps once per realm
  libceph: fix socket write error handling
  libceph: fix socket read error handling
  • Loading branch information
torvalds committed Feb 21, 2011
2 parents b08b69a + 97d79b4 commit 8bd89ca
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
5 changes: 4 additions & 1 deletion fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int ceph_init_dentry(struct dentry *dentry)
}
di->dentry = dentry;
di->lease_session = NULL;
di->parent_inode = igrab(dentry->d_parent->d_inode);
dentry->d_fsdata = di;
dentry->d_time = jiffies;
ceph_dentry_lru_add(dentry);
Expand Down Expand Up @@ -1033,7 +1034,7 @@ static void ceph_dentry_release(struct dentry *dentry)
u64 snapid = CEPH_NOSNAP;

if (!IS_ROOT(dentry)) {
parent_inode = dentry->d_parent->d_inode;
parent_inode = di->parent_inode;
if (parent_inode)
snapid = ceph_snap(parent_inode);
}
Expand All @@ -1058,6 +1059,8 @@ static void ceph_dentry_release(struct dentry *dentry)
kmem_cache_free(ceph_dentry_cachep, di);
dentry->d_fsdata = NULL;
}
if (parent_inode)
iput(parent_inode);
}

static int ceph_snapdir_d_revalidate(struct dentry *dentry,
Expand Down
14 changes: 10 additions & 4 deletions fs/ceph/snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,14 @@ static void queue_realm_cap_snaps(struct ceph_snap_realm *realm)
if (lastinode)
iput(lastinode);

dout("queue_realm_cap_snaps %p %llx children\n", realm, realm->ino);
list_for_each_entry(child, &realm->children, child_item)
queue_realm_cap_snaps(child);
list_for_each_entry(child, &realm->children, child_item) {
dout("queue_realm_cap_snaps %p %llx queue child %p %llx\n",
realm, realm->ino, child, child->ino);
list_del_init(&child->dirty_item);
list_add(&child->dirty_item, &realm->dirty_item);
}

list_del_init(&realm->dirty_item);
dout("queue_realm_cap_snaps %p %llx done\n", realm, realm->ino);
}

Expand Down Expand Up @@ -683,7 +687,9 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
* queue cap snaps _after_ we've built the new snap contexts,
* so that i_head_snapc can be set appropriately.
*/
list_for_each_entry(realm, &dirty_realms, dirty_item) {
while (!list_empty(&dirty_realms)) {
realm = list_first_entry(&dirty_realms, struct ceph_snap_realm,
dirty_item);
queue_realm_cap_snaps(realm);
}

Expand Down
1 change: 1 addition & 0 deletions fs/ceph/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ struct ceph_dentry_info {
struct dentry *dentry;
u64 time;
u64 offset;
struct inode *parent_inode;
};

struct ceph_inode_xattrs_info {
Expand Down
62 changes: 31 additions & 31 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,12 @@ static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
{
struct kvec iov = {buf, len};
struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
int r;

return kernel_recvmsg(sock, &msg, &iov, 1, len, msg.msg_flags);
r = kernel_recvmsg(sock, &msg, &iov, 1, len, msg.msg_flags);
if (r == -EAGAIN)
r = 0;
return r;
}

/*
Expand All @@ -264,13 +268,17 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov,
size_t kvlen, size_t len, int more)
{
struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
int r;

if (more)
msg.msg_flags |= MSG_MORE;
else
msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */

return kernel_sendmsg(sock, &msg, iov, kvlen, len);
r = kernel_sendmsg(sock, &msg, iov, kvlen, len);
if (r == -EAGAIN)
r = 0;
return r;
}


Expand Down Expand Up @@ -847,6 +855,8 @@ static int write_partial_msg_pages(struct ceph_connection *con)
(msg->pages || msg->pagelist || msg->bio || in_trail))
kunmap(page);

if (ret == -EAGAIN)
ret = 0;
if (ret <= 0)
goto out;

Expand Down Expand Up @@ -1737,16 +1747,12 @@ static int try_write(struct ceph_connection *con)
if (con->out_skip) {
ret = write_partial_skip(con);
if (ret <= 0)
goto done;
if (ret < 0) {
dout("try_write write_partial_skip err %d\n", ret);
goto done;
}
goto out;
}
if (con->out_kvec_left) {
ret = write_partial_kvec(con);
if (ret <= 0)
goto done;
goto out;
}

/* msg pages? */
Expand All @@ -1761,11 +1767,11 @@ static int try_write(struct ceph_connection *con)
if (ret == 1)
goto more_kvec; /* we need to send the footer, too! */
if (ret == 0)
goto done;
goto out;
if (ret < 0) {
dout("try_write write_partial_msg_pages err %d\n",
ret);
goto done;
goto out;
}
}

Expand All @@ -1789,10 +1795,9 @@ static int try_write(struct ceph_connection *con)
/* Nothing to do! */
clear_bit(WRITE_PENDING, &con->state);
dout("try_write nothing else to write.\n");
done:
ret = 0;
out:
dout("try_write done on %p\n", con);
dout("try_write done on %p ret %d\n", con, ret);
return ret;
}

Expand Down Expand Up @@ -1821,19 +1826,17 @@ static int try_read(struct ceph_connection *con)
dout("try_read connecting\n");
ret = read_partial_banner(con);
if (ret <= 0)
goto done;
if (process_banner(con) < 0) {
ret = -1;
goto out;
}
ret = process_banner(con);
if (ret < 0)
goto out;
}
ret = read_partial_connect(con);
if (ret <= 0)
goto done;
if (process_connect(con) < 0) {
ret = -1;
goto out;
}
ret = process_connect(con);
if (ret < 0)
goto out;
goto more;
}

Expand All @@ -1848,7 +1851,7 @@ static int try_read(struct ceph_connection *con)
dout("skipping %d / %d bytes\n", skip, -con->in_base_pos);
ret = ceph_tcp_recvmsg(con->sock, buf, skip);
if (ret <= 0)
goto done;
goto out;
con->in_base_pos += ret;
if (con->in_base_pos)
goto more;
Expand All @@ -1859,7 +1862,7 @@ static int try_read(struct ceph_connection *con)
*/
ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1);
if (ret <= 0)
goto done;
goto out;
dout("try_read got tag %d\n", (int)con->in_tag);
switch (con->in_tag) {
case CEPH_MSGR_TAG_MSG:
Expand All @@ -1870,7 +1873,7 @@ static int try_read(struct ceph_connection *con)
break;
case CEPH_MSGR_TAG_CLOSE:
set_bit(CLOSED, &con->state); /* fixme */
goto done;
goto out;
default:
goto bad_tag;
}
Expand All @@ -1882,13 +1885,12 @@ static int try_read(struct ceph_connection *con)
case -EBADMSG:
con->error_msg = "bad crc";
ret = -EIO;
goto out;
break;
case -EIO:
con->error_msg = "io error";
goto out;
default:
goto done;
break;
}
goto out;
}
if (con->in_tag == CEPH_MSGR_TAG_READY)
goto more;
Expand All @@ -1898,15 +1900,13 @@ static int try_read(struct ceph_connection *con)
if (con->in_tag == CEPH_MSGR_TAG_ACK) {
ret = read_partial_ack(con);
if (ret <= 0)
goto done;
goto out;
process_ack(con);
goto more;
}

done:
ret = 0;
out:
dout("try_read done on %p\n", con);
dout("try_read done on %p ret %d\n", con, ret);
return ret;

bad_tag:
Expand Down

0 comments on commit 8bd89ca

Please sign in to comment.