Commit 653f42f6 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
  ceph: add missing spin_unlock at ceph_mdsc_build_path()
  ceph: fix SEEK_CUR, SEEK_SET regression
  crush: fix mapping calculation when force argument doesn't exist
  ceph: use i_ceph_lock instead of i_lock
  rbd: remove buggy rollback functionality
  rbd: return an error when an invalid header is read
  ceph: fix rasize reporting by ceph_show_options
parents 4dde6ded 9d5a09e6
...@@ -57,13 +57,6 @@ create_snap ...@@ -57,13 +57,6 @@ create_snap
$ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_create $ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_create
rollback_snap
Rolls back data to the specified snapshot. This goes over the entire
list of rados blocks and sends a rollback command to each.
$ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_rollback
snap_* snap_*
A directory per each snapshot A directory per each snapshot
......
...@@ -183,10 +183,6 @@ static LIST_HEAD(rbd_client_list); /* clients */ ...@@ -183,10 +183,6 @@ static LIST_HEAD(rbd_client_list); /* clients */
static int __rbd_init_snaps_header(struct rbd_device *rbd_dev); static int __rbd_init_snaps_header(struct rbd_device *rbd_dev);
static void rbd_dev_release(struct device *dev); static void rbd_dev_release(struct device *dev);
static ssize_t rbd_snap_rollback(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t size);
static ssize_t rbd_snap_add(struct device *dev, static ssize_t rbd_snap_add(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
...@@ -461,6 +457,10 @@ static int rbd_header_from_disk(struct rbd_image_header *header, ...@@ -461,6 +457,10 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
u32 snap_count = le32_to_cpu(ondisk->snap_count); u32 snap_count = le32_to_cpu(ondisk->snap_count);
int ret = -ENOMEM; int ret = -ENOMEM;
if (memcmp(ondisk, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT))) {
return -ENXIO;
}
init_rwsem(&header->snap_rwsem); init_rwsem(&header->snap_rwsem);
header->snap_names_len = le64_to_cpu(ondisk->snap_names_len); header->snap_names_len = le64_to_cpu(ondisk->snap_names_len);
header->snapc = kmalloc(sizeof(struct ceph_snap_context) + header->snapc = kmalloc(sizeof(struct ceph_snap_context) +
...@@ -1355,32 +1355,6 @@ static int rbd_req_sync_notify(struct rbd_device *dev, ...@@ -1355,32 +1355,6 @@ static int rbd_req_sync_notify(struct rbd_device *dev,
return ret; return ret;
} }
/*
* Request sync osd rollback
*/
static int rbd_req_sync_rollback_obj(struct rbd_device *dev,
u64 snapid,
const char *obj)
{
struct ceph_osd_req_op *ops;
int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_ROLLBACK, 0);
if (ret < 0)
return ret;
ops[0].snap.snapid = snapid;
ret = rbd_req_sync_op(dev, NULL,
CEPH_NOSNAP,
0,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
ops,
1, obj, 0, 0, NULL, NULL, NULL);
rbd_destroy_ops(ops);
return ret;
}
/* /*
* Request sync osd read * Request sync osd read
*/ */
...@@ -1610,8 +1584,13 @@ static int rbd_read_header(struct rbd_device *rbd_dev, ...@@ -1610,8 +1584,13 @@ static int rbd_read_header(struct rbd_device *rbd_dev,
goto out_dh; goto out_dh;
rc = rbd_header_from_disk(header, dh, snap_count, GFP_KERNEL); rc = rbd_header_from_disk(header, dh, snap_count, GFP_KERNEL);
if (rc < 0) if (rc < 0) {
if (rc == -ENXIO) {
pr_warning("unrecognized header format"
" for image %s", rbd_dev->obj);
}
goto out_dh; goto out_dh;
}
if (snap_count != header->total_snaps) { if (snap_count != header->total_snaps) {
snap_count = header->total_snaps; snap_count = header->total_snaps;
...@@ -1882,7 +1861,6 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL); ...@@ -1882,7 +1861,6 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
static DEVICE_ATTR(create_snap, S_IWUSR, NULL, rbd_snap_add); static DEVICE_ATTR(create_snap, S_IWUSR, NULL, rbd_snap_add);
static DEVICE_ATTR(rollback_snap, S_IWUSR, NULL, rbd_snap_rollback);
static struct attribute *rbd_attrs[] = { static struct attribute *rbd_attrs[] = {
&dev_attr_size.attr, &dev_attr_size.attr,
...@@ -1893,7 +1871,6 @@ static struct attribute *rbd_attrs[] = { ...@@ -1893,7 +1871,6 @@ static struct attribute *rbd_attrs[] = {
&dev_attr_current_snap.attr, &dev_attr_current_snap.attr,
&dev_attr_refresh.attr, &dev_attr_refresh.attr,
&dev_attr_create_snap.attr, &dev_attr_create_snap.attr,
&dev_attr_rollback_snap.attr,
NULL NULL
}; };
...@@ -2424,64 +2401,6 @@ static ssize_t rbd_snap_add(struct device *dev, ...@@ -2424,64 +2401,6 @@ static ssize_t rbd_snap_add(struct device *dev,
return ret; return ret;
} }
static ssize_t rbd_snap_rollback(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
struct rbd_device *rbd_dev = dev_to_rbd(dev);
int ret;
u64 snapid;
u64 cur_ofs;
char *seg_name = NULL;
char *snap_name = kmalloc(count + 1, GFP_KERNEL);
ret = -ENOMEM;
if (!snap_name)
return ret;
/* parse snaps add command */
snprintf(snap_name, count, "%s", buf);
seg_name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO);
if (!seg_name)
goto done;
mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
ret = snap_by_name(&rbd_dev->header, snap_name, &snapid, NULL);
if (ret < 0)
goto done_unlock;
dout("snapid=%lld\n", snapid);
cur_ofs = 0;
while (cur_ofs < rbd_dev->header.image_size) {
cur_ofs += rbd_get_segment(&rbd_dev->header,
rbd_dev->obj,
cur_ofs, (u64)-1,
seg_name, NULL);
dout("seg_name=%s\n", seg_name);
ret = rbd_req_sync_rollback_obj(rbd_dev, snapid, seg_name);
if (ret < 0)
pr_warning("could not roll back obj %s err=%d\n",
seg_name, ret);
}
ret = __rbd_update_snaps(rbd_dev);
if (ret < 0)
goto done_unlock;
ret = count;
done_unlock:
mutex_unlock(&ctl_mutex);
done:
kfree(seg_name);
kfree(snap_name);
return ret;
}
static struct bus_attribute rbd_bus_attrs[] = { static struct bus_attribute rbd_bus_attrs[] = {
__ATTR(add, S_IWUSR, NULL, rbd_add), __ATTR(add, S_IWUSR, NULL, rbd_add),
__ATTR(remove, S_IWUSR, NULL, rbd_remove), __ATTR(remove, S_IWUSR, NULL, rbd_remove),
......
...@@ -87,7 +87,7 @@ static int ceph_set_page_dirty(struct page *page) ...@@ -87,7 +87,7 @@ static int ceph_set_page_dirty(struct page *page)
snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context); snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
/* dirty the head */ /* dirty the head */
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_head_snapc == NULL) if (ci->i_head_snapc == NULL)
ci->i_head_snapc = ceph_get_snap_context(snapc); ci->i_head_snapc = ceph_get_snap_context(snapc);
++ci->i_wrbuffer_ref_head; ++ci->i_wrbuffer_ref_head;
...@@ -100,7 +100,7 @@ static int ceph_set_page_dirty(struct page *page) ...@@ -100,7 +100,7 @@ static int ceph_set_page_dirty(struct page *page)
ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref_head-1, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref_head-1,
ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head, ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
snapc, snapc->seq, snapc->num_snaps); snapc, snapc->seq, snapc->num_snaps);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
/* now adjust page */ /* now adjust page */
spin_lock_irq(&mapping->tree_lock); spin_lock_irq(&mapping->tree_lock);
...@@ -391,7 +391,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode, ...@@ -391,7 +391,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
struct ceph_snap_context *snapc = NULL; struct ceph_snap_context *snapc = NULL;
struct ceph_cap_snap *capsnap = NULL; struct ceph_cap_snap *capsnap = NULL;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
dout(" cap_snap %p snapc %p has %d dirty pages\n", capsnap, dout(" cap_snap %p snapc %p has %d dirty pages\n", capsnap,
capsnap->context, capsnap->dirty_pages); capsnap->context, capsnap->dirty_pages);
...@@ -407,7 +407,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode, ...@@ -407,7 +407,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
dout(" head snapc %p has %d dirty pages\n", dout(" head snapc %p has %d dirty pages\n",
snapc, ci->i_wrbuffer_ref_head); snapc, ci->i_wrbuffer_ref_head);
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return snapc; return snapc;
} }
......
This diff is collapsed.
...@@ -281,18 +281,18 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -281,18 +281,18 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
} }
/* can we use the dcache? */ /* can we use the dcache? */
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if ((filp->f_pos == 2 || fi->dentry) && if ((filp->f_pos == 2 || fi->dentry) &&
!ceph_test_mount_opt(fsc, NOASYNCREADDIR) && !ceph_test_mount_opt(fsc, NOASYNCREADDIR) &&
ceph_snap(inode) != CEPH_SNAPDIR && ceph_snap(inode) != CEPH_SNAPDIR &&
ceph_dir_test_complete(inode) && ceph_dir_test_complete(inode) &&
__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1)) { __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1)) {
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
err = __dcache_readdir(filp, dirent, filldir); err = __dcache_readdir(filp, dirent, filldir);
if (err != -EAGAIN) if (err != -EAGAIN)
return err; return err;
} else { } else {
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
if (fi->dentry) { if (fi->dentry) {
err = note_last_dentry(fi, fi->dentry->d_name.name, err = note_last_dentry(fi, fi->dentry->d_name.name,
...@@ -428,12 +428,12 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -428,12 +428,12 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
* were released during the whole readdir, and we should have * were released during the whole readdir, and we should have
* the complete dir contents in our cache. * the complete dir contents in our cache.
*/ */
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_release_count == fi->dir_release_count) { if (ci->i_release_count == fi->dir_release_count) {
ceph_dir_set_complete(inode); ceph_dir_set_complete(inode);
ci->i_max_offset = filp->f_pos; ci->i_max_offset = filp->f_pos;
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
dout("readdir %p filp %p done.\n", inode, filp); dout("readdir %p filp %p done.\n", inode, filp);
return 0; return 0;
...@@ -607,7 +607,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, ...@@ -607,7 +607,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
struct ceph_inode_info *ci = ceph_inode(dir); struct ceph_inode_info *ci = ceph_inode(dir);
struct ceph_dentry_info *di = ceph_dentry(dentry); struct ceph_dentry_info *di = ceph_dentry(dentry);
spin_lock(&dir->i_lock); spin_lock(&ci->i_ceph_lock);
dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags); dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags);
if (strncmp(dentry->d_name.name, if (strncmp(dentry->d_name.name,
fsc->mount_options->snapdir_name, fsc->mount_options->snapdir_name,
...@@ -615,13 +615,13 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, ...@@ -615,13 +615,13 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
!is_root_ceph_dentry(dir, dentry) && !is_root_ceph_dentry(dir, dentry) &&
ceph_dir_test_complete(dir) && ceph_dir_test_complete(dir) &&
(__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1))) { (__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1))) {
spin_unlock(&dir->i_lock); spin_unlock(&ci->i_ceph_lock);
dout(" dir %p complete, -ENOENT\n", dir); dout(" dir %p complete, -ENOENT\n", dir);
d_add(dentry, NULL); d_add(dentry, NULL);
di->lease_shared_gen = ci->i_shared_gen; di->lease_shared_gen = ci->i_shared_gen;
return NULL; return NULL;
} }
spin_unlock(&dir->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
op = ceph_snap(dir) == CEPH_SNAPDIR ? op = ceph_snap(dir) == CEPH_SNAPDIR ?
...@@ -841,12 +841,12 @@ static int drop_caps_for_unlink(struct inode *inode) ...@@ -841,12 +841,12 @@ static int drop_caps_for_unlink(struct inode *inode)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (inode->i_nlink == 1) { if (inode->i_nlink == 1) {
drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN);
ci->i_ceph_flags |= CEPH_I_NODELAY; ci->i_ceph_flags |= CEPH_I_NODELAY;
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return drop; return drop;
} }
...@@ -1015,10 +1015,10 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) ...@@ -1015,10 +1015,10 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry)
struct ceph_dentry_info *di = ceph_dentry(dentry); struct ceph_dentry_info *di = ceph_dentry(dentry);
int valid = 0; int valid = 0;
spin_lock(&dir->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_shared_gen == di->lease_shared_gen) if (ci->i_shared_gen == di->lease_shared_gen)
valid = __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1); valid = __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1);
spin_unlock(&dir->i_lock); spin_unlock(&ci->i_ceph_lock);
dout("dir_lease_is_valid dir %p v%u dentry %p v%u = %d\n", dout("dir_lease_is_valid dir %p v%u dentry %p v%u = %d\n",
dir, (unsigned)ci->i_shared_gen, dentry, dir, (unsigned)ci->i_shared_gen, dentry,
(unsigned)di->lease_shared_gen, valid); (unsigned)di->lease_shared_gen, valid);
......
...@@ -147,9 +147,9 @@ int ceph_open(struct inode *inode, struct file *file) ...@@ -147,9 +147,9 @@ int ceph_open(struct inode *inode, struct file *file)
/* trivially open snapdir */ /* trivially open snapdir */
if (ceph_snap(inode) == CEPH_SNAPDIR) { if (ceph_snap(inode) == CEPH_SNAPDIR) {
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
__ceph_get_fmode(ci, fmode); __ceph_get_fmode(ci, fmode);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return ceph_init_file(inode, file, fmode); return ceph_init_file(inode, file, fmode);
} }
...@@ -158,7 +158,7 @@ int ceph_open(struct inode *inode, struct file *file) ...@@ -158,7 +158,7 @@ int ceph_open(struct inode *inode, struct file *file)
* write) or any MDS (for read). Update wanted set * write) or any MDS (for read). Update wanted set
* asynchronously. * asynchronously.
*/ */
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (__ceph_is_any_real_caps(ci) && if (__ceph_is_any_real_caps(ci) &&
(((fmode & CEPH_FILE_MODE_WR) == 0) || ci->i_auth_cap)) { (((fmode & CEPH_FILE_MODE_WR) == 0) || ci->i_auth_cap)) {
int mds_wanted = __ceph_caps_mds_wanted(ci); int mds_wanted = __ceph_caps_mds_wanted(ci);
...@@ -168,7 +168,7 @@ int ceph_open(struct inode *inode, struct file *file) ...@@ -168,7 +168,7 @@ int ceph_open(struct inode *inode, struct file *file)
inode, fmode, ceph_cap_string(wanted), inode, fmode, ceph_cap_string(wanted),
ceph_cap_string(issued)); ceph_cap_string(issued));
__ceph_get_fmode(ci, fmode); __ceph_get_fmode(ci, fmode);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
/* adjust wanted? */ /* adjust wanted? */
if ((issued & wanted) != wanted && if ((issued & wanted) != wanted &&
...@@ -180,10 +180,10 @@ int ceph_open(struct inode *inode, struct file *file) ...@@ -180,10 +180,10 @@ int ceph_open(struct inode *inode, struct file *file)
} else if (ceph_snap(inode) != CEPH_NOSNAP && } else if (ceph_snap(inode) != CEPH_NOSNAP &&
(ci->i_snap_caps & wanted) == wanted) { (ci->i_snap_caps & wanted) == wanted) {
__ceph_get_fmode(ci, fmode); __ceph_get_fmode(ci, fmode);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return ceph_init_file(inode, file, fmode); return ceph_init_file(inode, file, fmode);
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
dout("open fmode %d wants %s\n", fmode, ceph_cap_string(wanted)); dout("open fmode %d wants %s\n", fmode, ceph_cap_string(wanted));
req = prepare_open_request(inode->i_sb, flags, 0); req = prepare_open_request(inode->i_sb, flags, 0);
...@@ -743,9 +743,9 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -743,9 +743,9 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
*/ */
int dirty; int dirty;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR); dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
ceph_put_cap_refs(ci, got); ceph_put_cap_refs(ci, got);
ret = generic_file_aio_write(iocb, iov, nr_segs, pos); ret = generic_file_aio_write(iocb, iov, nr_segs, pos);
...@@ -764,9 +764,9 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -764,9 +764,9 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (ret >= 0) { if (ret >= 0) {
int dirty; int dirty;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR); dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (dirty) if (dirty)
__mark_inode_dirty(inode, dirty); __mark_inode_dirty(inode, dirty);
} }
...@@ -797,7 +797,8 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin) ...@@ -797,7 +797,8 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int origin)
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
__ceph_do_pending_vmtruncate(inode); __ceph_do_pending_vmtruncate(inode);
if (origin != SEEK_CUR || origin != SEEK_SET) {
if (origin == SEEK_END || origin == SEEK_DATA || origin == SEEK_HOLE) {
ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE); ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
if (ret < 0) { if (ret < 0) {
offset = ret; offset = ret;
......
...@@ -297,6 +297,8 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ...@@ -297,6 +297,8 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
dout("alloc_inode %p\n", &ci->vfs_inode); dout("alloc_inode %p\n", &ci->vfs_inode);
spin_lock_init(&ci->i_ceph_lock);
ci->i_version = 0; ci->i_version = 0;
ci->i_time_warp_seq = 0; ci->i_time_warp_seq = 0;
ci->i_ceph_flags = 0; ci->i_ceph_flags = 0;
...@@ -583,7 +585,7 @@ static int fill_inode(struct inode *inode, ...@@ -583,7 +585,7 @@ static int fill_inode(struct inode *inode,
iinfo->xattr_len); iinfo->xattr_len);
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
/* /*
* provided version will be odd if inode value is projected, * provided version will be odd if inode value is projected,
...@@ -680,7 +682,7 @@ static int fill_inode(struct inode *inode, ...@@ -680,7 +682,7 @@ static int fill_inode(struct inode *inode,
char *sym; char *sym;
BUG_ON(symlen != inode->i_size); BUG_ON(symlen != inode->i_size);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
err = -ENOMEM; err = -ENOMEM;
sym = kmalloc(symlen+1, GFP_NOFS); sym = kmalloc(symlen+1, GFP_NOFS);
...@@ -689,7 +691,7 @@ static int fill_inode(struct inode *inode, ...@@ -689,7 +691,7 @@ static int fill_inode(struct inode *inode,
memcpy(sym, iinfo->symlink, symlen); memcpy(sym, iinfo->symlink, symlen);
sym[symlen] = 0; sym[symlen] = 0;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (!ci->i_symlink) if (!ci->i_symlink)
ci->i_symlink = sym; ci->i_symlink = sym;
else else
...@@ -715,7 +717,7 @@ static int fill_inode(struct inode *inode, ...@@ -715,7 +717,7 @@ static int fill_inode(struct inode *inode,
} }
no_change: no_change:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
/* queue truncate if we saw i_size decrease */ /* queue truncate if we saw i_size decrease */
if (queue_trunc) if (queue_trunc)
...@@ -750,13 +752,13 @@ static int fill_inode(struct inode *inode, ...@@ -750,13 +752,13 @@ static int fill_inode(struct inode *inode,
info->cap.flags, info->cap.flags,
caps_reservation); caps_reservation);
} else { } else {
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dout(" %p got snap_caps %s\n", inode, dout(" %p got snap_caps %s\n", inode,
ceph_cap_string(le32_to_cpu(info->cap.caps))); ceph_cap_string(le32_to_cpu(info->cap.caps)));
ci->i_snap_caps |= le32_to_cpu(info->cap.caps); ci->i_snap_caps |= le32_to_cpu(info->cap.caps);
if (cap_fmode >= 0) if (cap_fmode >= 0)
__ceph_get_fmode(ci, cap_fmode); __ceph_get_fmode(ci, cap_fmode);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
} else if (cap_fmode >= 0) { } else if (cap_fmode >= 0) {
pr_warning("mds issued no caps on %llx.%llx\n", pr_warning("mds issued no caps on %llx.%llx\n",
...@@ -849,19 +851,20 @@ static void ceph_set_dentry_offset(struct dentry *dn) ...@@ -849,19 +851,20 @@ static void ceph_set_dentry_offset(struct dentry *dn)
{ {
struct dentry *dir = dn->d_parent; struct dentry *dir = dn->d_parent;
struct inode *inode = dir->d_inode; struct inode *inode = dir->d_inode;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_dentry_info *di; struct ceph_dentry_info *di;
BUG_ON(!inode); BUG_ON(!inode);
di = ceph_dentry(dn); di = ceph_dentry(dn);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (!ceph_dir_test_complete(inode)) { if (!ceph_dir_test_complete(inode)) {
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return; return;
} }
di->offset = ceph_inode(inode)->i_max_offset++; di->offset = ceph_inode(inode)->i_max_offset++;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
spin_lock(&dir->d_lock); spin_lock(&dir->d_lock);
spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED);
...@@ -1308,7 +1311,7 @@ int ceph_inode_set_size(struct inode *inode, loff_t size) ...@@ -1308,7 +1311,7 @@ int ceph_inode_set_size(struct inode *inode, loff_t size)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
int ret = 0; int ret = 0;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dout("set_size %p %llu -> %llu\n", inode, inode->i_size, size); dout("set_size %p %llu -> %llu\n", inode, inode->i_size, size);
inode->i_size = size; inode->i_size = size;
inode->i_blocks = (size + (1 << 9) - 1) >> 9; inode->i_blocks = (size + (1 << 9) - 1) >> 9;
...@@ -1318,7 +1321,7 @@ int ceph_inode_set_size(struct inode *inode, loff_t size) ...@@ -1318,7 +1321,7 @@ int ceph_inode_set_size(struct inode *inode, loff_t size)
(ci->i_reported_size << 1) < ci->i_max_size) (ci->i_reported_size << 1) < ci->i_max_size)
ret = 1; ret = 1;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return ret; return ret;
} }
...@@ -1376,20 +1379,20 @@ static void ceph_invalidate_work(struct work_struct *work) ...@@ -1376,20 +1379,20 @@ static void ceph_invalidate_work(struct work_struct *work)
u32 orig_gen; u32 orig_gen;
int check = 0; int check = 0;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dout("invalidate_pages %p gen %d revoking %d\n", inode, dout("invalidate_pages %p gen %d revoking %d\n", inode,
ci->i_rdcache_gen, ci->i_rdcache_revoking); ci->i_rdcache_gen, ci->i_rdcache_revoking);
if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
/* nevermind! */ /* nevermind! */
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
goto out; goto out;
} }
orig_gen = ci->i_rdcache_gen; orig_gen = ci->i_rdcache_gen;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
truncate_inode_pages(&inode->i_data, 0); truncate_inode_pages(&inode->i_data, 0);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (orig_gen == ci->i_rdcache_gen && if (orig_gen == ci->i_rdcache_gen &&
orig_gen == ci->i_rdcache_revoking) { orig_gen == ci->i_rdcache_revoking) {
dout("invalidate_pages %p gen %d successful\n", inode, dout("invalidate_pages %p gen %d successful\n", inode,
...@@ -1401,7 +1404,7 @@ static void ceph_invalidate_work(struct work_struct *work) ...@@ -1401,7 +1404,7 @@ static void ceph_invalidate_work(struct work_struct *work)
inode, orig_gen, ci->i_rdcache_gen, inode, orig_gen, ci->i_rdcache_gen,
ci->i_rdcache_revoking); ci->i_rdcache_revoking);
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (check) if (check)
ceph_check_caps(ci, 0, NULL); ceph_check_caps(ci, 0, NULL);
...@@ -1460,10 +1463,10 @@ void __ceph_do_pending_vmtruncate(struct inode *inode) ...@@ -1460,10 +1463,10 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
int wrbuffer_refs, wake = 0; int wrbuffer_refs, wake = 0;
retry: retry:
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_truncate_pending == 0) { if (ci->i_truncate_pending == 0) {
dout("__do_pending_vmtruncate %p none pending\n", inode); dout("__do_pending_vmtruncate %p none pending\n", inode);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return; return;
} }
...@@ -1474,7 +1477,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode) ...@@ -1474,7 +1477,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
if (ci->i_wrbuffer_ref_head < ci->i_wrbuffer_ref) { if (ci->i_wrbuffer_ref_head < ci->i_wrbuffer_ref) {
dout("__do_pending_vmtruncate %p flushing snaps first\n", dout("__do_pending_vmtruncate %p flushing snaps first\n",
inode); inode);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
filemap_write_and_wait_range(&inode->i_data, 0, filemap_write_and_wait_range(&inode->i_data, 0,
inode->i_sb->s_maxbytes); inode->i_sb->s_maxbytes);
goto retry; goto retry;
...@@ -1484,15 +1487,15 @@ void __ceph_do_pending_vmtruncate(struct inode *inode) ...@@ -1484,15 +1487,15 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
wrbuffer_refs = ci->i_wrbuffer_ref; wrbuffer_refs = ci->i_wrbuffer_ref;
dout("__do_pending_vmtruncate %p (%d) to %lld\n", inode, dout("__do_pending_vmtruncate %p (%d) to %lld\n", inode,
ci->i_truncate_pending, to); ci->i_truncate_pending, to);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
truncate_inode_pages(inode->i_mapping, to); truncate_inode_pages(inode->i_mapping, to);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
ci->i_truncate_pending--; ci->i_truncate_pending--;
if (ci->i_truncate_pending == 0) if (ci->i_truncate_pending == 0)
wake = 1; wake = 1;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (wrbuffer_refs == 0) if (wrbuffer_refs == 0)
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
...@@ -1547,7 +1550,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -1547,7 +1550,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
if (IS_ERR(req)) if (IS_ERR(req))
return PTR_ERR(req); return PTR_ERR(req);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
issued = __ceph_caps_issued(ci, NULL); issued = __ceph_caps_issued(ci, NULL);
dout("setattr %p issued %s\n", inode, ceph_cap_string(issued)); dout("setattr %p issued %s\n", inode, ceph_cap_string(issued));
...@@ -1695,7 +1698,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -1695,7 +1698,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
} }
release &= issued; release &= issued;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (inode_dirty_flags) if (inode_dirty_flags)
__mark_inode_dirty(inode, inode_dirty_flags); __mark_inode_dirty(inode, inode_dirty_flags);
...@@ -1717,7 +1720,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -1717,7 +1720,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
__ceph_do_pending_vmtruncate(inode); __ceph_do_pending_vmtruncate(inode);
return err; return err;
out: out:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
ceph_mdsc_put_request(req); ceph_mdsc_put_request(req);
return err; return err;
} }
......
...@@ -241,11 +241,11 @@ static long ceph_ioctl_lazyio(struct file *file) ...@@ -241,11 +241,11 @@ static long ceph_ioctl_lazyio(struct file *file)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
if ((fi->fmode & CEPH_FILE_MODE_LAZY) == 0) { if ((fi->fmode & CEPH_FILE_MODE_LAZY) == 0) {
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
ci->i_nr_by_mode[fi->fmode]--; ci->i_nr_by_mode[fi->fmode]--;
fi->fmode |= CEPH_FILE_MODE_LAZY; fi->fmode |= CEPH_FILE_MODE_LAZY;
ci->i_nr_by_mode[fi->fmode]++; ci->i_nr_by_mode[fi->fmode]++;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
dout("ioctl_layzio: file %p marked lazy\n", file); dout("ioctl_layzio: file %p marked lazy\n", file);
ceph_check_caps(ci, 0, NULL); ceph_check_caps(ci, 0, NULL);
......
...@@ -732,21 +732,21 @@ static int __choose_mds(struct ceph_mds_client *mdsc, ...@@ -732,21 +732,21 @@ static int __choose_mds(struct ceph_mds_client *mdsc,
} }
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
cap = NULL; cap = NULL;
if (mode == USE_AUTH_MDS) if (mode == USE_AUTH_MDS)
cap = ci->i_auth_cap; cap = ci->i_auth_cap;
if (!cap && !RB_EMPTY_ROOT(&ci->i_caps)) if (!cap && !RB_EMPTY_ROOT(&ci->i_caps))
cap = rb_entry(rb_first(&ci->i_caps), struct ceph_cap, ci_node); cap = rb_entry(rb_first(&ci->i_caps), struct ceph_cap, ci_node);
if (!cap) { if (!cap) {
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
goto random; goto random;
} }
mds = cap->session->s_mds; mds = cap->session->s_mds;
dout("choose_mds %p %llx.%llx mds%d (%scap %p)\n", dout("choose_mds %p %llx.%llx mds%d (%scap %p)\n",
inode, ceph_vinop(inode), mds, inode, ceph_vinop(inode), mds,
cap == ci->i_auth_cap ? "auth " : "", cap); cap == ci->i_auth_cap ? "auth " : "", cap);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return mds; return mds;
random: random:
...@@ -951,7 +951,7 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -951,7 +951,7 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
dout("removing cap %p, ci is %p, inode is %p\n", dout("removing cap %p, ci is %p, inode is %p\n",
cap, ci, &ci->vfs_inode); cap, ci, &ci->vfs_inode);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
__ceph_remove_cap(cap); __ceph_remove_cap(cap);
if (!__ceph_is_any_real_caps(ci)) { if (!__ceph_is_any_real_caps(ci)) {
struct ceph_mds_client *mdsc = struct ceph_mds_client *mdsc =
...@@ -984,7 +984,7 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -984,7 +984,7 @@ static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
} }
spin_unlock(&mdsc->cap_dirty_lock); spin_unlock(&mdsc->cap_dirty_lock);
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
while (drop--) while (drop--)
iput(inode); iput(inode);
return 0; return 0;
...@@ -1015,10 +1015,10 @@ static int wake_up_session_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -1015,10 +1015,10 @@ static int wake_up_session_cb(struct inode *inode, struct ceph_cap *cap,
wake_up_all(&ci->i_cap_wq); wake_up_all(&ci->i_cap_wq);
if (arg) { if (arg) {
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
ci->i_wanted_max_size = 0; ci->i_wanted_max_size = 0;
ci->i_requested_max_size = 0; ci->i_requested_max_size = 0;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
return 0; return 0;
} }
...@@ -1151,7 +1151,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg) ...@@ -1151,7 +1151,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
if (session->s_trim_caps <= 0) if (session->s_trim_caps <= 0)
return -1; return -1;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
mine = cap->issued | cap->implemented; mine = cap->issued | cap->implemented;
used = __ceph_caps_used(ci); used = __ceph_caps_used(ci);
oissued = __ceph_caps_issued_other(ci, cap); oissued = __ceph_caps_issued_other(ci, cap);
...@@ -1170,7 +1170,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg) ...@@ -1170,7 +1170,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
__ceph_remove_cap(cap); __ceph_remove_cap(cap);
} else { } else {
/* try to drop referring dentries */ /* try to drop referring dentries */
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
d_prune_aliases(inode); d_prune_aliases(inode);
dout("trim_caps_cb %p cap %p pruned, count now %d\n", dout("trim_caps_cb %p cap %p pruned, count now %d\n",
inode, cap, atomic_read(&inode->i_count)); inode, cap, atomic_read(&inode->i_count));
...@@ -1178,7 +1178,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg) ...@@ -1178,7 +1178,7 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
} }
out: out:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return 0; return 0;
} }
...@@ -1296,7 +1296,7 @@ static int check_cap_flush(struct ceph_mds_client *mdsc, u64 want_flush_seq) ...@@ -1296,7 +1296,7 @@ static int check_cap_flush(struct ceph_mds_client *mdsc, u64 want_flush_seq)
i_flushing_item); i_flushing_item);
struct inode *inode = &ci->vfs_inode; struct inode *inode = &ci->vfs_inode;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_cap_flush_seq <= want_flush_seq) { if (ci->i_cap_flush_seq <= want_flush_seq) {
dout("check_cap_flush still flushing %p " dout("check_cap_flush still flushing %p "
"seq %lld <= %lld to mds%d\n", inode, "seq %lld <= %lld to mds%d\n", inode,
...@@ -1304,7 +1304,7 @@ static int check_cap_flush(struct ceph_mds_client *mdsc, u64 want_flush_seq) ...@@ -1304,7 +1304,7 @@ static int check_cap_flush(struct ceph_mds_client *mdsc, u64 want_flush_seq)
session->s_mds); session->s_mds);
ret = 0; ret = 0;
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
mutex_unlock(&session->s_mutex); mutex_unlock(&session->s_mutex);
ceph_put_mds_session(session); ceph_put_mds_session(session);
...@@ -1495,6 +1495,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base, ...@@ -1495,6 +1495,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
pos, temp); pos, temp);
} else if (stop_on_nosnap && inode && } else if (stop_on_nosnap && inode &&
ceph_snap(inode) == CEPH_NOSNAP) { ceph_snap(inode) == CEPH_NOSNAP) {
spin_unlock(&temp->d_lock);
break; break;
} else { } else {
pos -= temp->d_name.len; pos -= temp->d_name.len;
...@@ -2011,10 +2012,10 @@ void ceph_invalidate_dir_request(struct ceph_mds_request *req) ...@@ -2011,10 +2012,10 @@ void ceph_invalidate_dir_request(struct ceph_mds_request *req)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
dout("invalidate_dir_request %p (D_COMPLETE, lease(s))\n", inode); dout("invalidate_dir_request %p (D_COMPLETE, lease(s))\n", inode);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
ceph_dir_clear_complete(inode); ceph_dir_clear_complete(inode);
ci->i_release_count++; ci->i_release_count++;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (req->r_dentry) if (req->r_dentry)
ceph_invalidate_dentry_lease(req->r_dentry); ceph_invalidate_dentry_lease(req->r_dentry);
...@@ -2422,7 +2423,7 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -2422,7 +2423,7 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
if (err) if (err)
goto out_free; goto out_free;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
cap->seq = 0; /* reset cap seq */ cap->seq = 0; /* reset cap seq */
cap->issue_seq = 0; /* and issue_seq */ cap->issue_seq = 0; /* and issue_seq */
...@@ -2445,7 +2446,7 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap, ...@@ -2445,7 +2446,7 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
rec.v1.pathbase = cpu_to_le64(pathbase); rec.v1.pathbase = cpu_to_le64(pathbase);
reclen = sizeof(rec.v1); reclen = sizeof(rec.v1);
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (recon_state->flock) { if (recon_state->flock) {
int num_fcntl_locks, num_flock_locks; int num_fcntl_locks, num_flock_locks;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* mdsc->snap_rwsem * mdsc->snap_rwsem
* *
* inode->i_lock * ci->i_ceph_lock
* mdsc->snap_flush_lock * mdsc->snap_flush_lock
* mdsc->cap_delay_lock * mdsc->cap_delay_lock
* *
......
...@@ -446,7 +446,7 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci) ...@@ -446,7 +446,7 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci)
return; return;
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
used = __ceph_caps_used(ci); used = __ceph_caps_used(ci);
dirty = __ceph_caps_dirty(ci); dirty = __ceph_caps_dirty(ci);
...@@ -528,7 +528,7 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci) ...@@ -528,7 +528,7 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci)
kfree(capsnap); kfree(capsnap);
} }
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
/* /*
...@@ -537,7 +537,7 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci) ...@@ -537,7 +537,7 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci)
* *
* If capsnap can now be flushed, add to snap_flush list, and return 1. * If capsnap can now be flushed, add to snap_flush list, and return 1.
* *
* Caller must hold i_lock. * Caller must hold i_ceph_lock.
*/ */
int __ceph_finish_cap_snap(struct ceph_inode_info *ci, int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
struct ceph_cap_snap *capsnap) struct ceph_cap_snap *capsnap)
...@@ -739,9 +739,9 @@ static void flush_snaps(struct ceph_mds_client *mdsc) ...@@ -739,9 +739,9 @@ static void flush_snaps(struct ceph_mds_client *mdsc)
inode = &ci->vfs_inode; inode = &ci->vfs_inode;
ihold(inode); ihold(inode);
spin_unlock(&mdsc->snap_flush_lock); spin_unlock(&mdsc->snap_flush_lock);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
__ceph_flush_snaps(ci, &session, 0); __ceph_flush_snaps(ci, &session, 0);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
iput(inode); iput(inode);
spin_lock(&mdsc->snap_flush_lock); spin_lock(&mdsc->snap_flush_lock);
} }
...@@ -847,7 +847,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc, ...@@ -847,7 +847,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc,
continue; continue;
ci = ceph_inode(inode); ci = ceph_inode(inode);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (!ci->i_snap_realm) if (!ci->i_snap_realm)
goto skip_inode; goto skip_inode;
/* /*
...@@ -876,7 +876,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc, ...@@ -876,7 +876,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc,
oldrealm = ci->i_snap_realm; oldrealm = ci->i_snap_realm;
ci->i_snap_realm = realm; ci->i_snap_realm = realm;
spin_unlock(&realm->inodes_with_caps_lock); spin_unlock(&realm->inodes_with_caps_lock);
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
ceph_get_snap_realm(mdsc, realm); ceph_get_snap_realm(mdsc, realm);
ceph_put_snap_realm(mdsc, oldrealm); ceph_put_snap_realm(mdsc, oldrealm);
...@@ -885,7 +885,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc, ...@@ -885,7 +885,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc,
continue; continue;
skip_inode: skip_inode:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
iput(inode); iput(inode);
} }
......
...@@ -383,7 +383,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) ...@@ -383,7 +383,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
if (fsopt->rsize != CEPH_RSIZE_DEFAULT) if (fsopt->rsize != CEPH_RSIZE_DEFAULT)
seq_printf(m, ",rsize=%d", fsopt->rsize); seq_printf(m, ",rsize=%d", fsopt->rsize);
if (fsopt->rasize != CEPH_RASIZE_DEFAULT) if (fsopt->rasize != CEPH_RASIZE_DEFAULT)
seq_printf(m, ",rasize=%d", fsopt->rsize); seq_printf(m, ",rasize=%d", fsopt->rasize);
if (fsopt->congestion_kb != default_congestion_kb()) if (fsopt->congestion_kb != default_congestion_kb())
seq_printf(m, ",write_congestion_kb=%d", fsopt->congestion_kb); seq_printf(m, ",write_congestion_kb=%d", fsopt->congestion_kb);
if (fsopt->caps_wanted_delay_min != CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT) if (fsopt->caps_wanted_delay_min != CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT)
......
...@@ -220,7 +220,7 @@ struct ceph_dentry_info { ...@@ -220,7 +220,7 @@ struct ceph_dentry_info {
* The locking for D_COMPLETE is a bit odd: * The locking for D_COMPLETE is a bit odd:
* - we can clear it at almost any time (see ceph_d_prune) * - we can clear it at almost any time (see ceph_d_prune)
* - it is only meaningful if: * - it is only meaningful if:
* - we hold dir inode i_lock * - we hold dir inode i_ceph_lock
* - we hold dir FILE_SHARED caps * - we hold dir FILE_SHARED caps
* - the dentry D_COMPLETE is set * - the dentry D_COMPLETE is set
*/ */
...@@ -250,6 +250,8 @@ struct ceph_inode_xattrs_info { ...@@ -250,6 +250,8 @@ struct ceph_inode_xattrs_info {
struct ceph_inode_info { struct ceph_inode_info {
struct ceph_vino i_vino; /* ceph ino + snap */ struct ceph_vino i_vino; /* ceph ino + snap */
spinlock_t i_ceph_lock;
u64 i_version; u64 i_version;
u32 i_time_warp_seq; u32 i_time_warp_seq;
...@@ -271,7 +273,7 @@ struct ceph_inode_info { ...@@ -271,7 +273,7 @@ struct ceph_inode_info {
struct ceph_inode_xattrs_info i_xattrs; struct ceph_inode_xattrs_info i_xattrs;
/* capabilities. protected _both_ by i_lock and cap->session's /* capabilities. protected _both_ by i_ceph_lock and cap->session's
* s_mutex. */ * s_mutex. */
struct rb_root i_caps; /* cap list */ struct rb_root i_caps; /* cap list */
struct ceph_cap *i_auth_cap; /* authoritative cap, if any */ struct ceph_cap *i_auth_cap; /* authoritative cap, if any */
...@@ -437,18 +439,18 @@ static inline void ceph_i_clear(struct inode *inode, unsigned mask) ...@@ -437,18 +439,18 @@ static inline void ceph_i_clear(struct inode *inode, unsigned mask)
{ {
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
ci->i_ceph_flags &= ~mask; ci->i_ceph_flags &= ~mask;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
static inline void ceph_i_set(struct inode *inode, unsigned mask) static inline void ceph_i_set(struct inode *inode, unsigned mask)
{ {
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
ci->i_ceph_flags |= mask; ci->i_ceph_flags |= mask;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
} }
static inline bool ceph_i_test(struct inode *inode, unsigned mask) static inline bool ceph_i_test(struct inode *inode, unsigned mask)
...@@ -456,9 +458,9 @@ static inline bool ceph_i_test(struct inode *inode, unsigned mask) ...@@ -456,9 +458,9 @@ static inline bool ceph_i_test(struct inode *inode, unsigned mask)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
bool r; bool r;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
r = (ci->i_ceph_flags & mask) == mask; r = (ci->i_ceph_flags & mask) == mask;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return r; return r;
} }
...@@ -508,9 +510,9 @@ extern int __ceph_caps_issued_other(struct ceph_inode_info *ci, ...@@ -508,9 +510,9 @@ extern int __ceph_caps_issued_other(struct ceph_inode_info *ci,
static inline int ceph_caps_issued(struct ceph_inode_info *ci) static inline int ceph_caps_issued(struct ceph_inode_info *ci)
{ {
int issued; int issued;
spin_lock(&ci->vfs_inode.i_lock); spin_lock(&ci->i_ceph_lock);
issued = __ceph_caps_issued(ci, NULL); issued = __ceph_caps_issued(ci, NULL);
spin_unlock(&ci->vfs_inode.i_lock); spin_unlock(&ci->i_ceph_lock);
return issued; return issued;
} }
...@@ -518,9 +520,9 @@ static inline int ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, ...@@ -518,9 +520,9 @@ static inline int ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask,
int touch) int touch)
{ {
int r; int r;
spin_lock(&ci->vfs_inode.i_lock); spin_lock(&ci->i_ceph_lock);
r = __ceph_caps_issued_mask(ci, mask, touch); r = __ceph_caps_issued_mask(ci, mask, touch);
spin_unlock(&ci->vfs_inode.i_lock); spin_unlock(&ci->i_ceph_lock);
return r; return r;
} }
...@@ -743,10 +745,9 @@ extern int ceph_add_cap(struct inode *inode, ...@@ -743,10 +745,9 @@ extern int ceph_add_cap(struct inode *inode,
extern void __ceph_remove_cap(struct ceph_cap *cap); extern void __ceph_remove_cap(struct ceph_cap *cap);
static inline void ceph_remove_cap(struct ceph_cap *cap) static inline void ceph_remove_cap(struct ceph_cap *cap)
{ {
struct inode *inode = &cap->ci->vfs_inode; spin_lock(&cap->ci->i_ceph_lock);
spin_lock(&inode->i_lock);
__ceph_remove_cap(cap); __ceph_remove_cap(cap);
spin_unlock(&inode->i_lock); spin_unlock(&cap->ci->i_ceph_lock);
} }
extern void ceph_put_cap(struct ceph_mds_client *mdsc, extern void ceph_put_cap(struct ceph_mds_client *mdsc,
struct ceph_cap *cap); struct ceph_cap *cap);
......
...@@ -343,8 +343,8 @@ void __ceph_destroy_xattrs(struct ceph_inode_info *ci) ...@@ -343,8 +343,8 @@ void __ceph_destroy_xattrs(struct ceph_inode_info *ci)
} }
static int __build_xattrs(struct inode *inode) static int __build_xattrs(struct inode *inode)
__releases(inode->i_lock) __releases(ci->i_ceph_lock)
__acquires(inode->i_lock) __acquires(ci->i_ceph_lock)
{ {
u32 namelen; u32 namelen;
u32 numattr = 0; u32 numattr = 0;
...@@ -372,7 +372,7 @@ static int __build_xattrs(struct inode *inode) ...@@ -372,7 +372,7 @@ static int __build_xattrs(struct inode *inode)
end = p + ci->i_xattrs.blob->vec.iov_len; end = p + ci->i_xattrs.blob->vec.iov_len;
ceph_decode_32_safe(&p, end, numattr, bad); ceph_decode_32_safe(&p, end, numattr, bad);
xattr_version = ci->i_xattrs.version; xattr_version = ci->i_xattrs.version;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *), xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
GFP_NOFS); GFP_NOFS);
...@@ -387,7 +387,7 @@ static int __build_xattrs(struct inode *inode) ...@@ -387,7 +387,7 @@ static int __build_xattrs(struct inode *inode)
goto bad_lock; goto bad_lock;
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_xattrs.version != xattr_version) { if (ci->i_xattrs.version != xattr_version) {
/* lost a race, retry */ /* lost a race, retry */
for (i = 0; i < numattr; i++) for (i = 0; i < numattr; i++)
...@@ -418,7 +418,7 @@ static int __build_xattrs(struct inode *inode) ...@@ -418,7 +418,7 @@ static int __build_xattrs(struct inode *inode)
return err; return err;
bad_lock: bad_lock:
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
bad: bad:
if (xattrs) { if (xattrs) {
for (i = 0; i < numattr; i++) for (i = 0; i < numattr; i++)
...@@ -512,7 +512,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, ...@@ -512,7 +512,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
if (vxattrs) if (vxattrs)
vxattr = ceph_match_vxattr(vxattrs, name); vxattr = ceph_match_vxattr(vxattrs, name);
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dout("getxattr %p ver=%lld index_ver=%lld\n", inode, dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
ci->i_xattrs.version, ci->i_xattrs.index_version); ci->i_xattrs.version, ci->i_xattrs.index_version);
...@@ -520,14 +520,14 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, ...@@ -520,14 +520,14 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
(ci->i_xattrs.index_version >= ci->i_xattrs.version)) { (ci->i_xattrs.index_version >= ci->i_xattrs.version)) {
goto get_xattr; goto get_xattr;
} else { } else {
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
/* get xattrs from mds (if we don't already have them) */ /* get xattrs from mds (if we don't already have them) */
err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR); err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR);
if (err) if (err)
return err; return err;
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (vxattr && vxattr->readonly) { if (vxattr && vxattr->readonly) {
err = vxattr->getxattr_cb(ci, value, size); err = vxattr->getxattr_cb(ci, value, size);
...@@ -558,7 +558,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value, ...@@ -558,7 +558,7 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
memcpy(value, xattr->val, xattr->val_len); memcpy(value, xattr->val, xattr->val_len);
out: out:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return err; return err;
} }
...@@ -573,7 +573,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) ...@@ -573,7 +573,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
u32 len; u32 len;
int i; int i;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
dout("listxattr %p ver=%lld index_ver=%lld\n", inode, dout("listxattr %p ver=%lld index_ver=%lld\n", inode,
ci->i_xattrs.version, ci->i_xattrs.index_version); ci->i_xattrs.version, ci->i_xattrs.index_version);
...@@ -581,13 +581,13 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) ...@@ -581,13 +581,13 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
(ci->i_xattrs.index_version >= ci->i_xattrs.version)) { (ci->i_xattrs.index_version >= ci->i_xattrs.version)) {
goto list_xattr; goto list_xattr;
} else { } else {
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR); err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR);
if (err) if (err)
return err; return err;
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
err = __build_xattrs(inode); err = __build_xattrs(inode);
if (err < 0) if (err < 0)
...@@ -619,7 +619,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) ...@@ -619,7 +619,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
} }
out: out:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
return err; return err;
} }
...@@ -739,7 +739,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name, ...@@ -739,7 +739,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
if (!xattr) if (!xattr)
goto out; goto out;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
retry: retry:
issued = __ceph_caps_issued(ci, NULL); issued = __ceph_caps_issued(ci, NULL);
if (!(issued & CEPH_CAP_XATTR_EXCL)) if (!(issued & CEPH_CAP_XATTR_EXCL))
...@@ -752,12 +752,12 @@ int ceph_setxattr(struct dentry *dentry, const char *name, ...@@ -752,12 +752,12 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) { required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) {
struct ceph_buffer *blob = NULL; struct ceph_buffer *blob = NULL;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
dout(" preaallocating new blob size=%d\n", required_blob_size); dout(" preaallocating new blob size=%d\n", required_blob_size);
blob = ceph_buffer_new(required_blob_size, GFP_NOFS); blob = ceph_buffer_new(required_blob_size, GFP_NOFS);
if (!blob) if (!blob)
goto out; goto out;
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
if (ci->i_xattrs.prealloc_blob) if (ci->i_xattrs.prealloc_blob)
ceph_buffer_put(ci->i_xattrs.prealloc_blob); ceph_buffer_put(ci->i_xattrs.prealloc_blob);
ci->i_xattrs.prealloc_blob = blob; ci->i_xattrs.prealloc_blob = blob;
...@@ -770,13 +770,13 @@ int ceph_setxattr(struct dentry *dentry, const char *name, ...@@ -770,13 +770,13 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
ci->i_xattrs.dirty = true; ci->i_xattrs.dirty = true;
inode->i_ctime = CURRENT_TIME; inode->i_ctime = CURRENT_TIME;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (dirty) if (dirty)
__mark_inode_dirty(inode, dirty); __mark_inode_dirty(inode, dirty);
return err; return err;
do_sync: do_sync:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
err = ceph_sync_setxattr(dentry, name, value, size, flags); err = ceph_sync_setxattr(dentry, name, value, size, flags);
out: out:
kfree(newname); kfree(newname);
...@@ -833,7 +833,7 @@ int ceph_removexattr(struct dentry *dentry, const char *name) ...@@ -833,7 +833,7 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
spin_lock(&inode->i_lock); spin_lock(&ci->i_ceph_lock);
__build_xattrs(inode); __build_xattrs(inode);
issued = __ceph_caps_issued(ci, NULL); issued = __ceph_caps_issued(ci, NULL);
dout("removexattr %p issued %s\n", inode, ceph_cap_string(issued)); dout("removexattr %p issued %s\n", inode, ceph_cap_string(issued));
...@@ -846,12 +846,12 @@ int ceph_removexattr(struct dentry *dentry, const char *name) ...@@ -846,12 +846,12 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
ci->i_xattrs.dirty = true; ci->i_xattrs.dirty = true;
inode->i_ctime = CURRENT_TIME; inode->i_ctime = CURRENT_TIME;
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
if (dirty) if (dirty)
__mark_inode_dirty(inode, dirty); __mark_inode_dirty(inode, dirty);
return err; return err;
do_sync: do_sync:
spin_unlock(&inode->i_lock); spin_unlock(&ci->i_ceph_lock);
err = ceph_send_removexattr(dentry, name); err = ceph_send_removexattr(dentry, name);
return err; return err;
} }
......
...@@ -477,7 +477,6 @@ int crush_do_rule(struct crush_map *map, ...@@ -477,7 +477,6 @@ int crush_do_rule(struct crush_map *map,
int i, j; int i, j;
int numrep; int numrep;
int firstn; int firstn;
int rc = -1;
BUG_ON(ruleno >= map->max_rules); BUG_ON(ruleno >= map->max_rules);
...@@ -491,23 +490,18 @@ int crush_do_rule(struct crush_map *map, ...@@ -491,23 +490,18 @@ int crush_do_rule(struct crush_map *map,
* that this may or may not correspond to the specific types * that this may or may not correspond to the specific types
* referenced by the crush rule. * referenced by the crush rule.
*/ */
if (force >= 0) { if (force >= 0 &&
if (force >= map->max_devices || force < map->max_devices &&
map->device_parents[force] == 0) { map->device_parents[force] != 0 &&
/*dprintk("CRUSH: forcefed device dne\n");*/ !is_out(map, weight, force, x)) {
rc = -1; /* force fed device dne */ while (1) {
goto out; force_context[++force_pos] = force;
} if (force >= 0)
if (!is_out(map, weight, force, x)) { force = map->device_parents[force];
while (1) { else
force_context[++force_pos] = force; force = map->bucket_parents[-1-force];
if (force >= 0) if (force == 0)
force = map->device_parents[force]; break;
else
force = map->bucket_parents[-1-force];
if (force == 0)
break;
}
} }
} }
...@@ -600,10 +594,7 @@ int crush_do_rule(struct crush_map *map, ...@@ -600,10 +594,7 @@ int crush_do_rule(struct crush_map *map,
BUG_ON(1); BUG_ON(1);
} }
} }
rc = result_len; return result_len;
out:
return rc;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment