rbd_dev 331 drivers/block/rbd.c struct rbd_device *rbd_dev; rbd_dev 505 drivers/block/rbd.c static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth); rbd_dev 517 drivers/block/rbd.c static bool __rbd_is_lock_owner(struct rbd_device *rbd_dev) rbd_dev 519 drivers/block/rbd.c lockdep_assert_held(&rbd_dev->lock_rwsem); rbd_dev 521 drivers/block/rbd.c return rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED || rbd_dev 522 drivers/block/rbd.c rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING; rbd_dev 525 drivers/block/rbd.c static bool rbd_is_lock_owner(struct rbd_device *rbd_dev) rbd_dev 529 drivers/block/rbd.c down_read(&rbd_dev->lock_rwsem); rbd_dev 530 drivers/block/rbd.c is_lock_owner = __rbd_is_lock_owner(rbd_dev); rbd_dev 531 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 587 drivers/block/rbd.c void rbd_warn(struct rbd_device *rbd_dev, const char *fmt, ...) rbd_dev 596 drivers/block/rbd.c if (!rbd_dev) rbd_dev 598 drivers/block/rbd.c else if (rbd_dev->disk) rbd_dev 600 drivers/block/rbd.c RBD_DRV_NAME, rbd_dev->disk->disk_name, &vaf); rbd_dev 601 drivers/block/rbd.c else if (rbd_dev->spec && rbd_dev->spec->image_name) rbd_dev 603 drivers/block/rbd.c RBD_DRV_NAME, rbd_dev->spec->image_name, &vaf); rbd_dev 604 drivers/block/rbd.c else if (rbd_dev->spec && rbd_dev->spec->image_id) rbd_dev 606 drivers/block/rbd.c RBD_DRV_NAME, rbd_dev->spec->image_id, &vaf); rbd_dev 609 drivers/block/rbd.c RBD_DRV_NAME, rbd_dev, &vaf); rbd_dev 626 drivers/block/rbd.c static void rbd_dev_remove_parent(struct rbd_device *rbd_dev); rbd_dev 628 drivers/block/rbd.c static int rbd_dev_refresh(struct rbd_device *rbd_dev); rbd_dev 629 drivers/block/rbd.c static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev); rbd_dev 630 drivers/block/rbd.c static int rbd_dev_header_info(struct rbd_device *rbd_dev); rbd_dev 631 drivers/block/rbd.c static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev); rbd_dev 632 drivers/block/rbd.c static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, rbd_dev 634 drivers/block/rbd.c static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 636 drivers/block/rbd.c static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 638 drivers/block/rbd.c static int rbd_dev_v2_get_flags(struct rbd_device *rbd_dev); rbd_dev 661 drivers/block/rbd.c struct rbd_device *rbd_dev = bdev->bd_disk->private_data; rbd_dev 664 drivers/block/rbd.c spin_lock_irq(&rbd_dev->lock); rbd_dev 665 drivers/block/rbd.c if (test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags)) rbd_dev 668 drivers/block/rbd.c rbd_dev->open_count++; rbd_dev 669 drivers/block/rbd.c spin_unlock_irq(&rbd_dev->lock); rbd_dev 673 drivers/block/rbd.c (void) get_device(&rbd_dev->dev); rbd_dev 680 drivers/block/rbd.c struct rbd_device *rbd_dev = disk->private_data; rbd_dev 683 drivers/block/rbd.c spin_lock_irq(&rbd_dev->lock); rbd_dev 684 drivers/block/rbd.c open_count_before = rbd_dev->open_count--; rbd_dev 685 drivers/block/rbd.c spin_unlock_irq(&rbd_dev->lock); rbd_dev 688 drivers/block/rbd.c put_device(&rbd_dev->dev); rbd_dev 691 drivers/block/rbd.c static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg) rbd_dev 699 drivers/block/rbd.c if (rbd_dev->spec->snap_id != CEPH_NOSNAP && !ro) rbd_dev 709 drivers/block/rbd.c struct rbd_device *rbd_dev = bdev->bd_disk->private_data; rbd_dev 714 drivers/block/rbd.c ret = rbd_ioctl_set_ro(rbd_dev, arg); rbd_dev 1085 drivers/block/rbd.c static void rbd_init_layout(struct rbd_device *rbd_dev) rbd_dev 1087 drivers/block/rbd.c if (rbd_dev->header.stripe_unit == 0 || rbd_dev 1088 drivers/block/rbd.c rbd_dev->header.stripe_count == 0) { rbd_dev 1089 drivers/block/rbd.c rbd_dev->header.stripe_unit = rbd_obj_bytes(&rbd_dev->header); rbd_dev 1090 drivers/block/rbd.c rbd_dev->header.stripe_count = 1; rbd_dev 1093 drivers/block/rbd.c rbd_dev->layout.stripe_unit = rbd_dev->header.stripe_unit; rbd_dev 1094 drivers/block/rbd.c rbd_dev->layout.stripe_count = rbd_dev->header.stripe_count; rbd_dev 1095 drivers/block/rbd.c rbd_dev->layout.object_size = rbd_obj_bytes(&rbd_dev->header); rbd_dev 1096 drivers/block/rbd.c rbd_dev->layout.pool_id = rbd_dev->header.data_pool_id == CEPH_NOPOOL ? rbd_dev 1097 drivers/block/rbd.c rbd_dev->spec->pool_id : rbd_dev->header.data_pool_id; rbd_dev 1098 drivers/block/rbd.c RCU_INIT_POINTER(rbd_dev->layout.pool_ns, NULL); rbd_dev 1105 drivers/block/rbd.c static int rbd_header_from_disk(struct rbd_device *rbd_dev, rbd_dev 1108 drivers/block/rbd.c struct rbd_image_header *header = &rbd_dev->header; rbd_dev 1176 drivers/block/rbd.c rbd_init_layout(rbd_dev); rbd_dev 1202 drivers/block/rbd.c static const char *_rbd_dev_v1_snap_name(struct rbd_device *rbd_dev, u32 which) rbd_dev 1206 drivers/block/rbd.c rbd_assert(which < rbd_dev->header.snapc->num_snaps); rbd_dev 1210 drivers/block/rbd.c snap_name = rbd_dev->header.snap_names; rbd_dev 1241 drivers/block/rbd.c static u32 rbd_dev_snap_index(struct rbd_device *rbd_dev, u64 snap_id) rbd_dev 1243 drivers/block/rbd.c struct ceph_snap_context *snapc = rbd_dev->header.snapc; rbd_dev 1252 drivers/block/rbd.c static const char *rbd_dev_v1_snap_name(struct rbd_device *rbd_dev, rbd_dev 1258 drivers/block/rbd.c which = rbd_dev_snap_index(rbd_dev, snap_id); rbd_dev 1262 drivers/block/rbd.c snap_name = _rbd_dev_v1_snap_name(rbd_dev, which); rbd_dev 1266 drivers/block/rbd.c static const char *rbd_snap_name(struct rbd_device *rbd_dev, u64 snap_id) rbd_dev 1271 drivers/block/rbd.c rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); rbd_dev 1272 drivers/block/rbd.c if (rbd_dev->image_format == 1) rbd_dev 1273 drivers/block/rbd.c return rbd_dev_v1_snap_name(rbd_dev, snap_id); rbd_dev 1275 drivers/block/rbd.c return rbd_dev_v2_snap_name(rbd_dev, snap_id); rbd_dev 1278 drivers/block/rbd.c static int rbd_snap_size(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 1281 drivers/block/rbd.c rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); rbd_dev 1283 drivers/block/rbd.c *snap_size = rbd_dev->header.image_size; rbd_dev 1284 drivers/block/rbd.c } else if (rbd_dev->image_format == 1) { rbd_dev 1287 drivers/block/rbd.c which = rbd_dev_snap_index(rbd_dev, snap_id); rbd_dev 1291 drivers/block/rbd.c *snap_size = rbd_dev->header.snap_sizes[which]; rbd_dev 1296 drivers/block/rbd.c ret = _rbd_dev_v2_snap_size(rbd_dev, snap_id, NULL, &size); rbd_dev 1305 drivers/block/rbd.c static int rbd_snap_features(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 1308 drivers/block/rbd.c rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); rbd_dev 1310 drivers/block/rbd.c *snap_features = rbd_dev->header.features; rbd_dev 1311 drivers/block/rbd.c } else if (rbd_dev->image_format == 1) { rbd_dev 1317 drivers/block/rbd.c ret = _rbd_dev_v2_snap_features(rbd_dev, snap_id, &features); rbd_dev 1326 drivers/block/rbd.c static int rbd_dev_mapping_set(struct rbd_device *rbd_dev) rbd_dev 1328 drivers/block/rbd.c u64 snap_id = rbd_dev->spec->snap_id; rbd_dev 1333 drivers/block/rbd.c ret = rbd_snap_size(rbd_dev, snap_id, &size); rbd_dev 1336 drivers/block/rbd.c ret = rbd_snap_features(rbd_dev, snap_id, &features); rbd_dev 1340 drivers/block/rbd.c rbd_dev->mapping.size = size; rbd_dev 1341 drivers/block/rbd.c rbd_dev->mapping.features = features; rbd_dev 1346 drivers/block/rbd.c static void rbd_dev_mapping_clear(struct rbd_device *rbd_dev) rbd_dev 1348 drivers/block/rbd.c rbd_dev->mapping.size = 0; rbd_dev 1349 drivers/block/rbd.c rbd_dev->mapping.features = 0; rbd_dev 1479 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 1482 drivers/block/rbd.c obj_req->ex.oe_len == rbd_dev->layout.object_size; rbd_dev 1487 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 1490 drivers/block/rbd.c rbd_dev->layout.object_size; rbd_dev 1568 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 1569 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 1571 drivers/block/rbd.c const char *name_format = rbd_dev->image_format == 1 ? rbd_dev 1587 drivers/block/rbd.c ceph_oloc_copy(&req->r_base_oloc, &rbd_dev->header_oloc); rbd_dev 1588 drivers/block/rbd.c req->r_base_oloc.pool = rbd_dev->layout.pool_id; rbd_dev 1591 drivers/block/rbd.c rbd_dev->header.object_prefix, rbd_dev 1667 drivers/block/rbd.c static void rbd_dev_unparent(struct rbd_device *rbd_dev) rbd_dev 1669 drivers/block/rbd.c rbd_dev_remove_parent(rbd_dev); rbd_dev 1670 drivers/block/rbd.c rbd_spec_put(rbd_dev->parent_spec); rbd_dev 1671 drivers/block/rbd.c rbd_dev->parent_spec = NULL; rbd_dev 1672 drivers/block/rbd.c rbd_dev->parent_overlap = 0; rbd_dev 1681 drivers/block/rbd.c static void rbd_dev_parent_put(struct rbd_device *rbd_dev) rbd_dev 1685 drivers/block/rbd.c if (!rbd_dev->parent_spec) rbd_dev 1688 drivers/block/rbd.c counter = atomic_dec_return_safe(&rbd_dev->parent_ref); rbd_dev 1695 drivers/block/rbd.c rbd_dev_unparent(rbd_dev); rbd_dev 1697 drivers/block/rbd.c rbd_warn(rbd_dev, "parent reference underflow"); rbd_dev 1708 drivers/block/rbd.c static bool rbd_dev_parent_get(struct rbd_device *rbd_dev) rbd_dev 1712 drivers/block/rbd.c if (!rbd_dev->parent_spec) rbd_dev 1715 drivers/block/rbd.c down_read(&rbd_dev->header_rwsem); rbd_dev 1716 drivers/block/rbd.c if (rbd_dev->parent_overlap) rbd_dev 1717 drivers/block/rbd.c counter = atomic_inc_return_safe(&rbd_dev->parent_ref); rbd_dev 1718 drivers/block/rbd.c up_read(&rbd_dev->header_rwsem); rbd_dev 1721 drivers/block/rbd.c rbd_warn(rbd_dev, "parent reference overflow"); rbd_dev 1732 drivers/block/rbd.c struct rbd_device *rbd_dev, rbd_dev 1742 drivers/block/rbd.c img_request->rbd_dev = rbd_dev; rbd_dev 1745 drivers/block/rbd.c img_request->snap_id = rbd_dev->spec->snap_id; rbd_dev 1749 drivers/block/rbd.c if (rbd_dev_parent_get(rbd_dev)) rbd_dev 1776 drivers/block/rbd.c rbd_dev_parent_put(img_request->rbd_dev); rbd_dev 1789 drivers/block/rbd.c static void __rbd_object_map_index(struct rbd_device *rbd_dev, u64 objno, rbd_dev 1794 drivers/block/rbd.c rbd_assert(objno < rbd_dev->object_map_size); rbd_dev 1799 drivers/block/rbd.c static u8 __rbd_object_map_get(struct rbd_device *rbd_dev, u64 objno) rbd_dev 1804 drivers/block/rbd.c lockdep_assert_held(&rbd_dev->object_map_lock); rbd_dev 1805 drivers/block/rbd.c __rbd_object_map_index(rbd_dev, objno, &index, &shift); rbd_dev 1806 drivers/block/rbd.c return (rbd_dev->object_map[index] >> shift) & OBJ_MASK; rbd_dev 1809 drivers/block/rbd.c static void __rbd_object_map_set(struct rbd_device *rbd_dev, u64 objno, u8 val) rbd_dev 1815 drivers/block/rbd.c lockdep_assert_held(&rbd_dev->object_map_lock); rbd_dev 1818 drivers/block/rbd.c __rbd_object_map_index(rbd_dev, objno, &index, &shift); rbd_dev 1819 drivers/block/rbd.c p = &rbd_dev->object_map[index]; rbd_dev 1823 drivers/block/rbd.c static u8 rbd_object_map_get(struct rbd_device *rbd_dev, u64 objno) rbd_dev 1827 drivers/block/rbd.c spin_lock(&rbd_dev->object_map_lock); rbd_dev 1828 drivers/block/rbd.c state = __rbd_object_map_get(rbd_dev, objno); rbd_dev 1829 drivers/block/rbd.c spin_unlock(&rbd_dev->object_map_lock); rbd_dev 1833 drivers/block/rbd.c static bool use_object_map(struct rbd_device *rbd_dev) rbd_dev 1835 drivers/block/rbd.c return ((rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP) && rbd_dev 1836 drivers/block/rbd.c !(rbd_dev->object_map_flags & RBD_FLAG_OBJECT_MAP_INVALID)); rbd_dev 1839 drivers/block/rbd.c static bool rbd_object_map_may_exist(struct rbd_device *rbd_dev, u64 objno) rbd_dev 1844 drivers/block/rbd.c if (!use_object_map(rbd_dev)) rbd_dev 1847 drivers/block/rbd.c state = rbd_object_map_get(rbd_dev, objno); rbd_dev 1851 drivers/block/rbd.c static void rbd_object_map_name(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 1856 drivers/block/rbd.c rbd_dev->spec->image_id); rbd_dev 1859 drivers/block/rbd.c rbd_dev->spec->image_id, snap_id); rbd_dev 1862 drivers/block/rbd.c static int rbd_object_map_lock(struct rbd_device *rbd_dev) rbd_dev 1864 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 1873 drivers/block/rbd.c rbd_object_map_name(rbd_dev, CEPH_NOSNAP, &oid); rbd_dev 1876 drivers/block/rbd.c ret = ceph_cls_lock(osdc, &oid, &rbd_dev->header_oloc, RBD_LOCK_NAME, rbd_dev 1882 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to lock object map: %d", ret); rbd_dev 1886 drivers/block/rbd.c ret = ceph_cls_lock_info(osdc, &oid, &rbd_dev->header_oloc, rbd_dev 1893 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to get object map lockers: %d", ret); rbd_dev 1901 drivers/block/rbd.c rbd_warn(rbd_dev, "breaking object map lock owned by %s%llu", rbd_dev 1904 drivers/block/rbd.c ret = ceph_cls_break_lock(osdc, &oid, &rbd_dev->header_oloc, rbd_dev 1912 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to break object map lock: %d", ret); rbd_dev 1920 drivers/block/rbd.c static void rbd_object_map_unlock(struct rbd_device *rbd_dev) rbd_dev 1922 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 1926 drivers/block/rbd.c rbd_object_map_name(rbd_dev, CEPH_NOSNAP, &oid); rbd_dev 1928 drivers/block/rbd.c ret = ceph_cls_unlock(osdc, &oid, &rbd_dev->header_oloc, RBD_LOCK_NAME, rbd_dev 1931 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to unlock object map: %d", ret); rbd_dev 1959 drivers/block/rbd.c static int __rbd_object_map_load(struct rbd_device *rbd_dev) rbd_dev 1961 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 1972 drivers/block/rbd.c rbd_assert(!rbd_dev->object_map && !rbd_dev->object_map_size); rbd_dev 1974 drivers/block/rbd.c num_objects = ceph_get_num_objects(&rbd_dev->layout, rbd_dev 1975 drivers/block/rbd.c rbd_dev->mapping.size); rbd_dev 1984 drivers/block/rbd.c rbd_object_map_name(rbd_dev, rbd_dev->spec->snap_id, &oid); rbd_dev 1985 drivers/block/rbd.c ret = ceph_osdc_call(osdc, &oid, &rbd_dev->header_oloc, rbd_dev 1998 drivers/block/rbd.c rbd_warn(rbd_dev, "object map size mismatch: %llu vs %llu", rbd_dev 2009 drivers/block/rbd.c rbd_dev->object_map = kvmalloc(object_map_bytes, GFP_KERNEL); rbd_dev 2010 drivers/block/rbd.c if (!rbd_dev->object_map) { rbd_dev 2015 drivers/block/rbd.c rbd_dev->object_map_size = object_map_size; rbd_dev 2016 drivers/block/rbd.c ceph_copy_from_page_vector(pages, rbd_dev->object_map, rbd_dev 2024 drivers/block/rbd.c static void rbd_object_map_free(struct rbd_device *rbd_dev) rbd_dev 2026 drivers/block/rbd.c kvfree(rbd_dev->object_map); rbd_dev 2027 drivers/block/rbd.c rbd_dev->object_map = NULL; rbd_dev 2028 drivers/block/rbd.c rbd_dev->object_map_size = 0; rbd_dev 2031 drivers/block/rbd.c static int rbd_object_map_load(struct rbd_device *rbd_dev) rbd_dev 2035 drivers/block/rbd.c ret = __rbd_object_map_load(rbd_dev); rbd_dev 2039 drivers/block/rbd.c ret = rbd_dev_v2_get_flags(rbd_dev); rbd_dev 2041 drivers/block/rbd.c rbd_object_map_free(rbd_dev); rbd_dev 2045 drivers/block/rbd.c if (rbd_dev->object_map_flags & RBD_FLAG_OBJECT_MAP_INVALID) rbd_dev 2046 drivers/block/rbd.c rbd_warn(rbd_dev, "object map is invalid"); rbd_dev 2051 drivers/block/rbd.c static int rbd_object_map_open(struct rbd_device *rbd_dev) rbd_dev 2055 drivers/block/rbd.c ret = rbd_object_map_lock(rbd_dev); rbd_dev 2059 drivers/block/rbd.c ret = rbd_object_map_load(rbd_dev); rbd_dev 2061 drivers/block/rbd.c rbd_object_map_unlock(rbd_dev); rbd_dev 2068 drivers/block/rbd.c static void rbd_object_map_close(struct rbd_device *rbd_dev) rbd_dev 2070 drivers/block/rbd.c rbd_object_map_free(rbd_dev); rbd_dev 2071 drivers/block/rbd.c rbd_object_map_unlock(rbd_dev); rbd_dev 2087 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 2119 drivers/block/rbd.c spin_lock(&rbd_dev->object_map_lock); rbd_dev 2120 drivers/block/rbd.c state = __rbd_object_map_get(rbd_dev, objno); rbd_dev 2123 drivers/block/rbd.c __rbd_object_map_set(rbd_dev, objno, new_state); rbd_dev 2124 drivers/block/rbd.c spin_unlock(&rbd_dev->object_map_lock); rbd_dev 2141 drivers/block/rbd.c static bool update_needed(struct rbd_device *rbd_dev, u64 objno, u8 new_state) rbd_dev 2143 drivers/block/rbd.c u8 state = rbd_object_map_get(rbd_dev, objno); rbd_dev 2194 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 2195 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 2202 drivers/block/rbd.c if (!update_needed(rbd_dev, obj_req->ex.oe_objno, new_state)) rbd_dev 2216 drivers/block/rbd.c rbd_object_map_name(rbd_dev, snap_id, &req->r_base_oid); rbd_dev 2217 drivers/block/rbd.c ceph_oloc_copy(&req->r_base_oloc, &rbd_dev->header_oloc); rbd_dev 2272 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 2275 drivers/block/rbd.c if (!rbd_dev->parent_overlap) rbd_dev 2278 drivers/block/rbd.c ret = ceph_extent_to_file(&rbd_dev->layout, obj_req->ex.oe_objno, rbd_dev 2280 drivers/block/rbd.c entire ? rbd_dev->layout.object_size : rbd_dev 2288 drivers/block/rbd.c rbd_dev->parent_overlap); rbd_dev 2363 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 2366 drivers/block/rbd.c if (!use_object_map(rbd_dev) || rbd_dev 2369 drivers/block/rbd.c rbd_dev->layout.object_size, rbd_dev 2370 drivers/block/rbd.c rbd_dev->layout.object_size); rbd_dev 2423 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 2435 drivers/block/rbd.c if (rbd_dev->opts->alloc_size != rbd_dev->layout.object_size || rbd_dev 2437 drivers/block/rbd.c off = round_up(obj_req->ex.oe_off, rbd_dev->opts->alloc_size); rbd_dev 2439 drivers/block/rbd.c rbd_dev->opts->alloc_size); rbd_dev 2518 drivers/block/rbd.c if (!use_object_map(img_req->rbd_dev) || rbd_dev 2650 drivers/block/rbd.c ret = ceph_file_to_extents(&img_req->rbd_dev->layout, rbd_dev 2681 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 2687 drivers/block/rbd.c !rbd_layout_is_fancy(&rbd_dev->layout)) rbd_dev 2702 drivers/block/rbd.c ret = ceph_file_to_extents(&rbd_dev->layout, rbd_dev 2726 drivers/block/rbd.c ret = ceph_iterate_extents(&rbd_dev->layout, rbd_dev 2897 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 2899 drivers/block/rbd.c if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) { rbd_dev 2937 drivers/block/rbd.c child_img_req = rbd_img_request_create(img_req->rbd_dev->parent, rbd_dev 2984 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3006 drivers/block/rbd.c if (*result == -ENOENT && rbd_dev->parent_overlap) { rbd_dev 3061 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3063 drivers/block/rbd.c if (rbd_object_map_may_exist(rbd_dev, obj_req->ex.oe_objno)) rbd_dev 3083 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3086 drivers/block/rbd.c if (!(rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP)) rbd_dev 3244 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3249 drivers/block/rbd.c rbd_dev->parent_overlap); rbd_dev 3269 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3277 drivers/block/rbd.c if (!(rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP)) rbd_dev 3284 drivers/block/rbd.c if ((rbd_dev->header.features & RBD_FEATURE_FAST_DIFF) && rbd_dev 3345 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3387 drivers/block/rbd.c rbd_warn(rbd_dev, "snap object map update failed: %d", rbd_dev 3419 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3422 drivers/block/rbd.c if (!(rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP)) rbd_dev 3434 drivers/block/rbd.c struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev; rbd_dev 3456 drivers/block/rbd.c rbd_warn(rbd_dev, "pre object map update failed: %d", rbd_dev 3493 drivers/block/rbd.c rbd_warn(rbd_dev, "copyup failed: %d", *result); rbd_dev 3507 drivers/block/rbd.c rbd_warn(rbd_dev, "post object map update failed: %d", rbd_dev 3522 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3534 drivers/block/rbd.c rbd_warn(rbd_dev, "%s at objno %llu %llu~%llu result %d", rbd_dev 3553 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3555 drivers/block/rbd.c if (!(rbd_dev->header.features & RBD_FEATURE_EXCLUSIVE_LOCK)) rbd_dev 3558 drivers/block/rbd.c if (rbd_dev->spec->snap_id != CEPH_NOSNAP) rbd_dev 3562 drivers/block/rbd.c if (rbd_dev->opts->lock_on_read || rbd_dev 3563 drivers/block/rbd.c (rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP)) rbd_dev 3571 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3574 drivers/block/rbd.c lockdep_assert_held(&rbd_dev->lock_rwsem); rbd_dev 3575 drivers/block/rbd.c locked = rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED; rbd_dev 3576 drivers/block/rbd.c spin_lock(&rbd_dev->lock_lists_lock); rbd_dev 3579 drivers/block/rbd.c list_add_tail(&img_req->lock_item, &rbd_dev->acquiring_list); rbd_dev 3581 drivers/block/rbd.c list_add_tail(&img_req->lock_item, &rbd_dev->running_list); rbd_dev 3582 drivers/block/rbd.c spin_unlock(&rbd_dev->lock_lists_lock); rbd_dev 3588 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3591 drivers/block/rbd.c lockdep_assert_held(&rbd_dev->lock_rwsem); rbd_dev 3592 drivers/block/rbd.c spin_lock(&rbd_dev->lock_lists_lock); rbd_dev 3595 drivers/block/rbd.c need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING && rbd_dev 3596 drivers/block/rbd.c list_empty(&rbd_dev->running_list)); rbd_dev 3597 drivers/block/rbd.c spin_unlock(&rbd_dev->lock_lists_lock); rbd_dev 3599 drivers/block/rbd.c complete(&rbd_dev->releasing_wait); rbd_dev 3604 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3612 drivers/block/rbd.c if (rbd_dev->opts->exclusive) { rbd_dev 3621 drivers/block/rbd.c dout("%s rbd_dev %p queueing lock_dwork\n", __func__, rbd_dev); rbd_dev 3622 drivers/block/rbd.c queue_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, 0); rbd_dev 3648 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3670 drivers/block/rbd.c __rbd_is_lock_owner(rbd_dev)); rbd_dev 3697 drivers/block/rbd.c struct rbd_device *rbd_dev = img_req->rbd_dev; rbd_dev 3701 drivers/block/rbd.c down_read(&rbd_dev->lock_rwsem); rbd_dev 3707 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 3716 drivers/block/rbd.c rbd_warn(rbd_dev, "%s%s result %d", rbd_dev 3753 drivers/block/rbd.c static struct rbd_client_id rbd_get_cid(struct rbd_device *rbd_dev) rbd_dev 3757 drivers/block/rbd.c mutex_lock(&rbd_dev->watch_mutex); rbd_dev 3758 drivers/block/rbd.c cid.gid = ceph_client_gid(rbd_dev->rbd_client->client); rbd_dev 3759 drivers/block/rbd.c cid.handle = rbd_dev->watch_cookie; rbd_dev 3760 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 3767 drivers/block/rbd.c static void rbd_set_owner_cid(struct rbd_device *rbd_dev, rbd_dev 3770 drivers/block/rbd.c dout("%s rbd_dev %p %llu-%llu -> %llu-%llu\n", __func__, rbd_dev, rbd_dev 3771 drivers/block/rbd.c rbd_dev->owner_cid.gid, rbd_dev->owner_cid.handle, rbd_dev 3773 drivers/block/rbd.c rbd_dev->owner_cid = *cid; /* struct */ rbd_dev 3776 drivers/block/rbd.c static void format_lock_cookie(struct rbd_device *rbd_dev, char *buf) rbd_dev 3778 drivers/block/rbd.c mutex_lock(&rbd_dev->watch_mutex); rbd_dev 3779 drivers/block/rbd.c sprintf(buf, "%s %llu", RBD_LOCK_COOKIE_PREFIX, rbd_dev->watch_cookie); rbd_dev 3780 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 3783 drivers/block/rbd.c static void __rbd_lock(struct rbd_device *rbd_dev, const char *cookie) rbd_dev 3785 drivers/block/rbd.c struct rbd_client_id cid = rbd_get_cid(rbd_dev); rbd_dev 3787 drivers/block/rbd.c rbd_dev->lock_state = RBD_LOCK_STATE_LOCKED; rbd_dev 3788 drivers/block/rbd.c strcpy(rbd_dev->lock_cookie, cookie); rbd_dev 3789 drivers/block/rbd.c rbd_set_owner_cid(rbd_dev, &cid); rbd_dev 3790 drivers/block/rbd.c queue_work(rbd_dev->task_wq, &rbd_dev->acquired_lock_work); rbd_dev 3796 drivers/block/rbd.c static int rbd_lock(struct rbd_device *rbd_dev) rbd_dev 3798 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 3802 drivers/block/rbd.c WARN_ON(__rbd_is_lock_owner(rbd_dev) || rbd_dev 3803 drivers/block/rbd.c rbd_dev->lock_cookie[0] != '\0'); rbd_dev 3805 drivers/block/rbd.c format_lock_cookie(rbd_dev, cookie); rbd_dev 3806 drivers/block/rbd.c ret = ceph_cls_lock(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, rbd_dev 3812 drivers/block/rbd.c __rbd_lock(rbd_dev, cookie); rbd_dev 3819 drivers/block/rbd.c static void rbd_unlock(struct rbd_device *rbd_dev) rbd_dev 3821 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 3824 drivers/block/rbd.c WARN_ON(!__rbd_is_lock_owner(rbd_dev) || rbd_dev 3825 drivers/block/rbd.c rbd_dev->lock_cookie[0] == '\0'); rbd_dev 3827 drivers/block/rbd.c ret = ceph_cls_unlock(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, rbd_dev 3828 drivers/block/rbd.c RBD_LOCK_NAME, rbd_dev->lock_cookie); rbd_dev 3830 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to unlock header: %d", ret); rbd_dev 3833 drivers/block/rbd.c rbd_dev->lock_state = RBD_LOCK_STATE_UNLOCKED; rbd_dev 3834 drivers/block/rbd.c rbd_dev->lock_cookie[0] = '\0'; rbd_dev 3835 drivers/block/rbd.c rbd_set_owner_cid(rbd_dev, &rbd_empty_cid); rbd_dev 3836 drivers/block/rbd.c queue_work(rbd_dev->task_wq, &rbd_dev->released_lock_work); rbd_dev 3839 drivers/block/rbd.c static int __rbd_notify_op_lock(struct rbd_device *rbd_dev, rbd_dev 3844 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 3845 drivers/block/rbd.c struct rbd_client_id cid = rbd_get_cid(rbd_dev); rbd_dev 3850 drivers/block/rbd.c dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op); rbd_dev 3858 drivers/block/rbd.c return ceph_osdc_notify(osdc, &rbd_dev->header_oid, rbd_dev 3859 drivers/block/rbd.c &rbd_dev->header_oloc, buf, buf_size, rbd_dev 3863 drivers/block/rbd.c static void rbd_notify_op_lock(struct rbd_device *rbd_dev, rbd_dev 3869 drivers/block/rbd.c __rbd_notify_op_lock(rbd_dev, notify_op, &reply_pages, &reply_len); rbd_dev 3875 drivers/block/rbd.c struct rbd_device *rbd_dev = container_of(work, struct rbd_device, rbd_dev 3878 drivers/block/rbd.c rbd_notify_op_lock(rbd_dev, RBD_NOTIFY_OP_ACQUIRED_LOCK); rbd_dev 3883 drivers/block/rbd.c struct rbd_device *rbd_dev = container_of(work, struct rbd_device, rbd_dev 3886 drivers/block/rbd.c rbd_notify_op_lock(rbd_dev, RBD_NOTIFY_OP_RELEASED_LOCK); rbd_dev 3889 drivers/block/rbd.c static int rbd_request_lock(struct rbd_device *rbd_dev) rbd_dev 3896 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 3898 drivers/block/rbd.c ret = __rbd_notify_op_lock(rbd_dev, RBD_NOTIFY_OP_REQUEST_LOCK, rbd_dev 3901 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to request lock: %d", ret); rbd_dev 3923 drivers/block/rbd.c rbd_warn(rbd_dev, rbd_dev 3933 drivers/block/rbd.c rbd_warn(rbd_dev, rbd_dev 3944 drivers/block/rbd.c rbd_warn(rbd_dev, "no lock owners detected"); rbd_dev 3961 drivers/block/rbd.c static void wake_lock_waiters(struct rbd_device *rbd_dev, int result) rbd_dev 3965 drivers/block/rbd.c dout("%s rbd_dev %p result %d\n", __func__, rbd_dev, result); rbd_dev 3966 drivers/block/rbd.c lockdep_assert_held_write(&rbd_dev->lock_rwsem); rbd_dev 3968 drivers/block/rbd.c cancel_delayed_work(&rbd_dev->lock_dwork); rbd_dev 3969 drivers/block/rbd.c if (!completion_done(&rbd_dev->acquire_wait)) { rbd_dev 3970 drivers/block/rbd.c rbd_assert(list_empty(&rbd_dev->acquiring_list) && rbd_dev 3971 drivers/block/rbd.c list_empty(&rbd_dev->running_list)); rbd_dev 3972 drivers/block/rbd.c rbd_dev->acquire_err = result; rbd_dev 3973 drivers/block/rbd.c complete_all(&rbd_dev->acquire_wait); rbd_dev 3977 drivers/block/rbd.c list_for_each_entry(img_req, &rbd_dev->acquiring_list, lock_item) { rbd_dev 3984 drivers/block/rbd.c list_splice_tail_init(&rbd_dev->acquiring_list, &rbd_dev->running_list); rbd_dev 3987 drivers/block/rbd.c static int get_lock_owner_info(struct rbd_device *rbd_dev, rbd_dev 3990 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 3995 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 3997 drivers/block/rbd.c ret = ceph_cls_lock_info(osdc, &rbd_dev->header_oid, rbd_dev 3998 drivers/block/rbd.c &rbd_dev->header_oloc, RBD_LOCK_NAME, rbd_dev 4004 drivers/block/rbd.c dout("%s rbd_dev %p no lockers detected\n", __func__, rbd_dev); rbd_dev 4009 drivers/block/rbd.c rbd_warn(rbd_dev, "locked by external mechanism, tag %s", rbd_dev 4016 drivers/block/rbd.c rbd_warn(rbd_dev, "shared lock type detected"); rbd_dev 4023 drivers/block/rbd.c rbd_warn(rbd_dev, "locked by external mechanism, cookie %s", rbd_dev 4034 drivers/block/rbd.c static int find_watcher(struct rbd_device *rbd_dev, rbd_dev 4037 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4044 drivers/block/rbd.c ret = ceph_osdc_list_watchers(osdc, &rbd_dev->header_oid, rbd_dev 4045 drivers/block/rbd.c &rbd_dev->header_oloc, &watchers, rbd_dev 4061 drivers/block/rbd.c rbd_dev, cid.gid, cid.handle); rbd_dev 4062 drivers/block/rbd.c rbd_set_owner_cid(rbd_dev, &cid); rbd_dev 4068 drivers/block/rbd.c dout("%s rbd_dev %p no watchers\n", __func__, rbd_dev); rbd_dev 4078 drivers/block/rbd.c static int rbd_try_lock(struct rbd_device *rbd_dev) rbd_dev 4080 drivers/block/rbd.c struct ceph_client *client = rbd_dev->rbd_client->client; rbd_dev 4086 drivers/block/rbd.c ret = rbd_lock(rbd_dev); rbd_dev 4091 drivers/block/rbd.c ret = get_lock_owner_info(rbd_dev, &lockers, &num_lockers); rbd_dev 4098 drivers/block/rbd.c ret = find_watcher(rbd_dev, lockers); rbd_dev 4102 drivers/block/rbd.c rbd_warn(rbd_dev, "breaking header lock owned by %s%llu", rbd_dev 4108 drivers/block/rbd.c rbd_warn(rbd_dev, "blacklist of %s%llu failed: %d", rbd_dev 4113 drivers/block/rbd.c ret = ceph_cls_break_lock(&client->osdc, &rbd_dev->header_oid, rbd_dev 4114 drivers/block/rbd.c &rbd_dev->header_oloc, RBD_LOCK_NAME, rbd_dev 4129 drivers/block/rbd.c static int rbd_post_acquire_action(struct rbd_device *rbd_dev) rbd_dev 4133 drivers/block/rbd.c if (rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP) { rbd_dev 4134 drivers/block/rbd.c ret = rbd_object_map_open(rbd_dev); rbd_dev 4148 drivers/block/rbd.c static int rbd_try_acquire_lock(struct rbd_device *rbd_dev) rbd_dev 4152 drivers/block/rbd.c down_read(&rbd_dev->lock_rwsem); rbd_dev 4153 drivers/block/rbd.c dout("%s rbd_dev %p read lock_state %d\n", __func__, rbd_dev, rbd_dev 4154 drivers/block/rbd.c rbd_dev->lock_state); rbd_dev 4155 drivers/block/rbd.c if (__rbd_is_lock_owner(rbd_dev)) { rbd_dev 4156 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 4160 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 4161 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4162 drivers/block/rbd.c dout("%s rbd_dev %p write lock_state %d\n", __func__, rbd_dev, rbd_dev 4163 drivers/block/rbd.c rbd_dev->lock_state); rbd_dev 4164 drivers/block/rbd.c if (__rbd_is_lock_owner(rbd_dev)) { rbd_dev 4165 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4169 drivers/block/rbd.c ret = rbd_try_lock(rbd_dev); rbd_dev 4171 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to lock header: %d", ret); rbd_dev 4178 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4182 drivers/block/rbd.c rbd_assert(rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED); rbd_dev 4183 drivers/block/rbd.c rbd_assert(list_empty(&rbd_dev->running_list)); rbd_dev 4185 drivers/block/rbd.c ret = rbd_post_acquire_action(rbd_dev); rbd_dev 4187 drivers/block/rbd.c rbd_warn(rbd_dev, "post-acquire action failed: %d", ret); rbd_dev 4193 drivers/block/rbd.c rbd_unlock(rbd_dev); rbd_dev 4197 drivers/block/rbd.c wake_lock_waiters(rbd_dev, ret); rbd_dev 4198 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4204 drivers/block/rbd.c struct rbd_device *rbd_dev = container_of(to_delayed_work(work), rbd_dev 4208 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4210 drivers/block/rbd.c ret = rbd_try_acquire_lock(rbd_dev); rbd_dev 4212 drivers/block/rbd.c dout("%s rbd_dev %p ret %d - done\n", __func__, rbd_dev, ret); rbd_dev 4216 drivers/block/rbd.c ret = rbd_request_lock(rbd_dev); rbd_dev 4220 drivers/block/rbd.c rbd_warn(rbd_dev, "peer will not release lock"); rbd_dev 4221 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4222 drivers/block/rbd.c wake_lock_waiters(rbd_dev, ret); rbd_dev 4223 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4225 drivers/block/rbd.c rbd_warn(rbd_dev, "error requesting lock: %d", ret); rbd_dev 4226 drivers/block/rbd.c mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, rbd_dev 4234 drivers/block/rbd.c rbd_dev); rbd_dev 4235 drivers/block/rbd.c mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, rbd_dev 4240 drivers/block/rbd.c static bool rbd_quiesce_lock(struct rbd_device *rbd_dev) rbd_dev 4244 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4245 drivers/block/rbd.c lockdep_assert_held_write(&rbd_dev->lock_rwsem); rbd_dev 4247 drivers/block/rbd.c if (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED) rbd_dev 4253 drivers/block/rbd.c rbd_dev->lock_state = RBD_LOCK_STATE_RELEASING; rbd_dev 4254 drivers/block/rbd.c rbd_assert(!completion_done(&rbd_dev->releasing_wait)); rbd_dev 4255 drivers/block/rbd.c need_wait = !list_empty(&rbd_dev->running_list); rbd_dev 4256 drivers/block/rbd.c downgrade_write(&rbd_dev->lock_rwsem); rbd_dev 4258 drivers/block/rbd.c wait_for_completion(&rbd_dev->releasing_wait); rbd_dev 4259 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 4261 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4262 drivers/block/rbd.c if (rbd_dev->lock_state != RBD_LOCK_STATE_RELEASING) rbd_dev 4265 drivers/block/rbd.c rbd_assert(list_empty(&rbd_dev->running_list)); rbd_dev 4269 drivers/block/rbd.c static void rbd_pre_release_action(struct rbd_device *rbd_dev) rbd_dev 4271 drivers/block/rbd.c if (rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP) rbd_dev 4272 drivers/block/rbd.c rbd_object_map_close(rbd_dev); rbd_dev 4275 drivers/block/rbd.c static void __rbd_release_lock(struct rbd_device *rbd_dev) rbd_dev 4277 drivers/block/rbd.c rbd_assert(list_empty(&rbd_dev->running_list)); rbd_dev 4279 drivers/block/rbd.c rbd_pre_release_action(rbd_dev); rbd_dev 4280 drivers/block/rbd.c rbd_unlock(rbd_dev); rbd_dev 4286 drivers/block/rbd.c static void rbd_release_lock(struct rbd_device *rbd_dev) rbd_dev 4288 drivers/block/rbd.c if (!rbd_quiesce_lock(rbd_dev)) rbd_dev 4291 drivers/block/rbd.c __rbd_release_lock(rbd_dev); rbd_dev 4300 drivers/block/rbd.c cancel_delayed_work(&rbd_dev->lock_dwork); rbd_dev 4305 drivers/block/rbd.c struct rbd_device *rbd_dev = container_of(work, struct rbd_device, rbd_dev 4308 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4309 drivers/block/rbd.c rbd_release_lock(rbd_dev); rbd_dev 4310 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4313 drivers/block/rbd.c static void maybe_kick_acquire(struct rbd_device *rbd_dev) rbd_dev 4317 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4318 drivers/block/rbd.c if (__rbd_is_lock_owner(rbd_dev)) rbd_dev 4321 drivers/block/rbd.c spin_lock(&rbd_dev->lock_lists_lock); rbd_dev 4322 drivers/block/rbd.c have_requests = !list_empty(&rbd_dev->acquiring_list); rbd_dev 4323 drivers/block/rbd.c spin_unlock(&rbd_dev->lock_lists_lock); rbd_dev 4324 drivers/block/rbd.c if (have_requests || delayed_work_pending(&rbd_dev->lock_dwork)) { rbd_dev 4325 drivers/block/rbd.c dout("%s rbd_dev %p kicking lock_dwork\n", __func__, rbd_dev); rbd_dev 4326 drivers/block/rbd.c mod_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, 0); rbd_dev 4330 drivers/block/rbd.c static void rbd_handle_acquired_lock(struct rbd_device *rbd_dev, u8 struct_v, rbd_dev 4340 drivers/block/rbd.c dout("%s rbd_dev %p cid %llu-%llu\n", __func__, rbd_dev, cid.gid, rbd_dev 4343 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4344 drivers/block/rbd.c if (rbd_cid_equal(&cid, &rbd_dev->owner_cid)) { rbd_dev 4349 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4353 drivers/block/rbd.c rbd_set_owner_cid(rbd_dev, &cid); rbd_dev 4354 drivers/block/rbd.c downgrade_write(&rbd_dev->lock_rwsem); rbd_dev 4356 drivers/block/rbd.c down_read(&rbd_dev->lock_rwsem); rbd_dev 4359 drivers/block/rbd.c maybe_kick_acquire(rbd_dev); rbd_dev 4360 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 4363 drivers/block/rbd.c static void rbd_handle_released_lock(struct rbd_device *rbd_dev, u8 struct_v, rbd_dev 4373 drivers/block/rbd.c dout("%s rbd_dev %p cid %llu-%llu\n", __func__, rbd_dev, cid.gid, rbd_dev 4376 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4377 drivers/block/rbd.c if (!rbd_cid_equal(&cid, &rbd_dev->owner_cid)) { rbd_dev 4379 drivers/block/rbd.c __func__, rbd_dev, cid.gid, cid.handle, rbd_dev 4380 drivers/block/rbd.c rbd_dev->owner_cid.gid, rbd_dev->owner_cid.handle); rbd_dev 4381 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4385 drivers/block/rbd.c rbd_set_owner_cid(rbd_dev, &rbd_empty_cid); rbd_dev 4386 drivers/block/rbd.c downgrade_write(&rbd_dev->lock_rwsem); rbd_dev 4388 drivers/block/rbd.c down_read(&rbd_dev->lock_rwsem); rbd_dev 4391 drivers/block/rbd.c maybe_kick_acquire(rbd_dev); rbd_dev 4392 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 4399 drivers/block/rbd.c static int rbd_handle_request_lock(struct rbd_device *rbd_dev, u8 struct_v, rbd_dev 4402 drivers/block/rbd.c struct rbd_client_id my_cid = rbd_get_cid(rbd_dev); rbd_dev 4411 drivers/block/rbd.c dout("%s rbd_dev %p cid %llu-%llu\n", __func__, rbd_dev, cid.gid, rbd_dev 4416 drivers/block/rbd.c down_read(&rbd_dev->lock_rwsem); rbd_dev 4417 drivers/block/rbd.c if (__rbd_is_lock_owner(rbd_dev)) { rbd_dev 4418 drivers/block/rbd.c if (rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED && rbd_dev 4419 drivers/block/rbd.c rbd_cid_equal(&rbd_dev->owner_cid, &rbd_empty_cid)) rbd_dev 4428 drivers/block/rbd.c if (rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED) { rbd_dev 4429 drivers/block/rbd.c if (!rbd_dev->opts->exclusive) { rbd_dev 4431 drivers/block/rbd.c __func__, rbd_dev); rbd_dev 4432 drivers/block/rbd.c queue_work(rbd_dev->task_wq, rbd_dev 4433 drivers/block/rbd.c &rbd_dev->unlock_work); rbd_dev 4442 drivers/block/rbd.c up_read(&rbd_dev->lock_rwsem); rbd_dev 4446 drivers/block/rbd.c static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, rbd_dev 4449 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4465 drivers/block/rbd.c ret = ceph_osdc_notify_ack(osdc, &rbd_dev->header_oid, rbd_dev 4466 drivers/block/rbd.c &rbd_dev->header_oloc, notify_id, cookie, rbd_dev 4469 drivers/block/rbd.c rbd_warn(rbd_dev, "acknowledge_notify failed: %d", ret); rbd_dev 4472 drivers/block/rbd.c static void rbd_acknowledge_notify(struct rbd_device *rbd_dev, u64 notify_id, rbd_dev 4475 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4476 drivers/block/rbd.c __rbd_acknowledge_notify(rbd_dev, notify_id, cookie, NULL); rbd_dev 4479 drivers/block/rbd.c static void rbd_acknowledge_notify_result(struct rbd_device *rbd_dev, rbd_dev 4482 drivers/block/rbd.c dout("%s rbd_dev %p result %d\n", __func__, rbd_dev, result); rbd_dev 4483 drivers/block/rbd.c __rbd_acknowledge_notify(rbd_dev, notify_id, cookie, &result); rbd_dev 4489 drivers/block/rbd.c struct rbd_device *rbd_dev = arg; rbd_dev 4498 drivers/block/rbd.c __func__, rbd_dev, cookie, notify_id, data_len); rbd_dev 4503 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to decode NotifyMessage: %d", rbd_dev 4515 drivers/block/rbd.c dout("%s rbd_dev %p notify_op %u\n", __func__, rbd_dev, notify_op); rbd_dev 4518 drivers/block/rbd.c rbd_handle_acquired_lock(rbd_dev, struct_v, &p); rbd_dev 4519 drivers/block/rbd.c rbd_acknowledge_notify(rbd_dev, notify_id, cookie); rbd_dev 4522 drivers/block/rbd.c rbd_handle_released_lock(rbd_dev, struct_v, &p); rbd_dev 4523 drivers/block/rbd.c rbd_acknowledge_notify(rbd_dev, notify_id, cookie); rbd_dev 4526 drivers/block/rbd.c ret = rbd_handle_request_lock(rbd_dev, struct_v, &p); rbd_dev 4528 drivers/block/rbd.c rbd_acknowledge_notify_result(rbd_dev, notify_id, rbd_dev 4531 drivers/block/rbd.c rbd_acknowledge_notify(rbd_dev, notify_id, cookie); rbd_dev 4534 drivers/block/rbd.c ret = rbd_dev_refresh(rbd_dev); rbd_dev 4536 drivers/block/rbd.c rbd_warn(rbd_dev, "refresh failed: %d", ret); rbd_dev 4538 drivers/block/rbd.c rbd_acknowledge_notify(rbd_dev, notify_id, cookie); rbd_dev 4541 drivers/block/rbd.c if (rbd_is_lock_owner(rbd_dev)) rbd_dev 4542 drivers/block/rbd.c rbd_acknowledge_notify_result(rbd_dev, notify_id, rbd_dev 4545 drivers/block/rbd.c rbd_acknowledge_notify(rbd_dev, notify_id, cookie); rbd_dev 4550 drivers/block/rbd.c static void __rbd_unregister_watch(struct rbd_device *rbd_dev); rbd_dev 4554 drivers/block/rbd.c struct rbd_device *rbd_dev = arg; rbd_dev 4556 drivers/block/rbd.c rbd_warn(rbd_dev, "encountered watch error: %d", err); rbd_dev 4558 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4559 drivers/block/rbd.c rbd_set_owner_cid(rbd_dev, &rbd_empty_cid); rbd_dev 4560 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4562 drivers/block/rbd.c mutex_lock(&rbd_dev->watch_mutex); rbd_dev 4563 drivers/block/rbd.c if (rbd_dev->watch_state == RBD_WATCH_STATE_REGISTERED) { rbd_dev 4564 drivers/block/rbd.c __rbd_unregister_watch(rbd_dev); rbd_dev 4565 drivers/block/rbd.c rbd_dev->watch_state = RBD_WATCH_STATE_ERROR; rbd_dev 4567 drivers/block/rbd.c queue_delayed_work(rbd_dev->task_wq, &rbd_dev->watch_dwork, 0); rbd_dev 4569 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4575 drivers/block/rbd.c static int __rbd_register_watch(struct rbd_device *rbd_dev) rbd_dev 4577 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4580 drivers/block/rbd.c rbd_assert(!rbd_dev->watch_handle); rbd_dev 4581 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4583 drivers/block/rbd.c handle = ceph_osdc_watch(osdc, &rbd_dev->header_oid, rbd_dev 4584 drivers/block/rbd.c &rbd_dev->header_oloc, rbd_watch_cb, rbd_dev 4585 drivers/block/rbd.c rbd_watch_errcb, rbd_dev); rbd_dev 4589 drivers/block/rbd.c rbd_dev->watch_handle = handle; rbd_dev 4596 drivers/block/rbd.c static void __rbd_unregister_watch(struct rbd_device *rbd_dev) rbd_dev 4598 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4601 drivers/block/rbd.c rbd_assert(rbd_dev->watch_handle); rbd_dev 4602 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4604 drivers/block/rbd.c ret = ceph_osdc_unwatch(osdc, rbd_dev->watch_handle); rbd_dev 4606 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to unwatch: %d", ret); rbd_dev 4608 drivers/block/rbd.c rbd_dev->watch_handle = NULL; rbd_dev 4611 drivers/block/rbd.c static int rbd_register_watch(struct rbd_device *rbd_dev) rbd_dev 4615 drivers/block/rbd.c mutex_lock(&rbd_dev->watch_mutex); rbd_dev 4616 drivers/block/rbd.c rbd_assert(rbd_dev->watch_state == RBD_WATCH_STATE_UNREGISTERED); rbd_dev 4617 drivers/block/rbd.c ret = __rbd_register_watch(rbd_dev); rbd_dev 4621 drivers/block/rbd.c rbd_dev->watch_state = RBD_WATCH_STATE_REGISTERED; rbd_dev 4622 drivers/block/rbd.c rbd_dev->watch_cookie = rbd_dev->watch_handle->linger_id; rbd_dev 4625 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4629 drivers/block/rbd.c static void cancel_tasks_sync(struct rbd_device *rbd_dev) rbd_dev 4631 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4633 drivers/block/rbd.c cancel_work_sync(&rbd_dev->acquired_lock_work); rbd_dev 4634 drivers/block/rbd.c cancel_work_sync(&rbd_dev->released_lock_work); rbd_dev 4635 drivers/block/rbd.c cancel_delayed_work_sync(&rbd_dev->lock_dwork); rbd_dev 4636 drivers/block/rbd.c cancel_work_sync(&rbd_dev->unlock_work); rbd_dev 4643 drivers/block/rbd.c static void rbd_unregister_watch(struct rbd_device *rbd_dev) rbd_dev 4645 drivers/block/rbd.c cancel_tasks_sync(rbd_dev); rbd_dev 4647 drivers/block/rbd.c mutex_lock(&rbd_dev->watch_mutex); rbd_dev 4648 drivers/block/rbd.c if (rbd_dev->watch_state == RBD_WATCH_STATE_REGISTERED) rbd_dev 4649 drivers/block/rbd.c __rbd_unregister_watch(rbd_dev); rbd_dev 4650 drivers/block/rbd.c rbd_dev->watch_state = RBD_WATCH_STATE_UNREGISTERED; rbd_dev 4651 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4653 drivers/block/rbd.c cancel_delayed_work_sync(&rbd_dev->watch_dwork); rbd_dev 4654 drivers/block/rbd.c ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc); rbd_dev 4660 drivers/block/rbd.c static void rbd_reacquire_lock(struct rbd_device *rbd_dev) rbd_dev 4662 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4666 drivers/block/rbd.c if (!rbd_quiesce_lock(rbd_dev)) rbd_dev 4669 drivers/block/rbd.c format_lock_cookie(rbd_dev, cookie); rbd_dev 4670 drivers/block/rbd.c ret = ceph_cls_set_cookie(osdc, &rbd_dev->header_oid, rbd_dev 4671 drivers/block/rbd.c &rbd_dev->header_oloc, RBD_LOCK_NAME, rbd_dev 4672 drivers/block/rbd.c CEPH_CLS_LOCK_EXCLUSIVE, rbd_dev->lock_cookie, rbd_dev 4676 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to update lock cookie: %d", rbd_dev 4683 drivers/block/rbd.c __rbd_release_lock(rbd_dev); rbd_dev 4684 drivers/block/rbd.c queue_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, 0); rbd_dev 4686 drivers/block/rbd.c __rbd_lock(rbd_dev, cookie); rbd_dev 4687 drivers/block/rbd.c wake_lock_waiters(rbd_dev, 0); rbd_dev 4693 drivers/block/rbd.c struct rbd_device *rbd_dev = container_of(to_delayed_work(work), rbd_dev 4697 drivers/block/rbd.c dout("%s rbd_dev %p\n", __func__, rbd_dev); rbd_dev 4699 drivers/block/rbd.c mutex_lock(&rbd_dev->watch_mutex); rbd_dev 4700 drivers/block/rbd.c if (rbd_dev->watch_state != RBD_WATCH_STATE_ERROR) { rbd_dev 4701 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4705 drivers/block/rbd.c ret = __rbd_register_watch(rbd_dev); rbd_dev 4707 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to reregister watch: %d", ret); rbd_dev 4709 drivers/block/rbd.c queue_delayed_work(rbd_dev->task_wq, rbd_dev 4710 drivers/block/rbd.c &rbd_dev->watch_dwork, rbd_dev 4712 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4716 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4717 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4718 drivers/block/rbd.c wake_lock_waiters(rbd_dev, ret); rbd_dev 4719 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4723 drivers/block/rbd.c rbd_dev->watch_state = RBD_WATCH_STATE_REGISTERED; rbd_dev 4724 drivers/block/rbd.c rbd_dev->watch_cookie = rbd_dev->watch_handle->linger_id; rbd_dev 4725 drivers/block/rbd.c mutex_unlock(&rbd_dev->watch_mutex); rbd_dev 4727 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 4728 drivers/block/rbd.c if (rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED) rbd_dev 4729 drivers/block/rbd.c rbd_reacquire_lock(rbd_dev); rbd_dev 4730 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 4732 drivers/block/rbd.c ret = rbd_dev_refresh(rbd_dev); rbd_dev 4734 drivers/block/rbd.c rbd_warn(rbd_dev, "reregistration refresh failed: %d", ret); rbd_dev 4741 drivers/block/rbd.c static int rbd_obj_method_sync(struct rbd_device *rbd_dev, rbd_dev 4750 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4797 drivers/block/rbd.c struct rbd_device *rbd_dev = rq->q->queuedata; rbd_dev 4833 drivers/block/rbd.c if (op_type != OBJ_OP_READ && rbd_dev->spec->snap_id != CEPH_NOSNAP) { rbd_dev 4834 drivers/block/rbd.c rbd_warn(rbd_dev, "%s on read-only snapshot", rbd_dev 4846 drivers/block/rbd.c if (!test_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags)) { rbd_dev 4848 drivers/block/rbd.c rbd_assert(rbd_dev->spec->snap_id != CEPH_NOSNAP); rbd_dev 4854 drivers/block/rbd.c rbd_warn(rbd_dev, "bad request range (%llu~%llu)", offset, rbd_dev 4862 drivers/block/rbd.c down_read(&rbd_dev->header_rwsem); rbd_dev 4863 drivers/block/rbd.c mapping_size = rbd_dev->mapping.size; rbd_dev 4865 drivers/block/rbd.c snapc = rbd_dev->header.snapc; rbd_dev 4868 drivers/block/rbd.c up_read(&rbd_dev->header_rwsem); rbd_dev 4871 drivers/block/rbd.c rbd_warn(rbd_dev, "beyond EOD (%llu~%llu > %llu)", offset, rbd_dev 4877 drivers/block/rbd.c img_request = rbd_img_request_create(rbd_dev, op_type, snapc); rbd_dev 4885 drivers/block/rbd.c dout("%s rbd_dev %p img_req %p %s %llu~%llu\n", __func__, rbd_dev, rbd_dev 4903 drivers/block/rbd.c rbd_warn(rbd_dev, "%s %llx at %llx result %d", rbd_dev 4920 drivers/block/rbd.c static void rbd_free_disk(struct rbd_device *rbd_dev) rbd_dev 4922 drivers/block/rbd.c blk_cleanup_queue(rbd_dev->disk->queue); rbd_dev 4923 drivers/block/rbd.c blk_mq_free_tag_set(&rbd_dev->tag_set); rbd_dev 4924 drivers/block/rbd.c put_disk(rbd_dev->disk); rbd_dev 4925 drivers/block/rbd.c rbd_dev->disk = NULL; rbd_dev 4928 drivers/block/rbd.c static int rbd_obj_read_sync(struct rbd_device *rbd_dev, rbd_dev 4934 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 4977 drivers/block/rbd.c static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev) rbd_dev 5004 drivers/block/rbd.c ret = rbd_obj_read_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 5005 drivers/block/rbd.c &rbd_dev->header_oloc, ondisk, size); rbd_dev 5010 drivers/block/rbd.c rbd_warn(rbd_dev, "short header read (want %zd got %d)", rbd_dev 5016 drivers/block/rbd.c rbd_warn(rbd_dev, "invalid header"); rbd_dev 5025 drivers/block/rbd.c ret = rbd_header_from_disk(rbd_dev, ondisk); rbd_dev 5036 drivers/block/rbd.c static void rbd_exists_validate(struct rbd_device *rbd_dev) rbd_dev 5040 drivers/block/rbd.c if (!test_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags)) rbd_dev 5043 drivers/block/rbd.c snap_id = rbd_dev->spec->snap_id; rbd_dev 5047 drivers/block/rbd.c if (rbd_dev_snap_index(rbd_dev, snap_id) == BAD_SNAP_INDEX) rbd_dev 5048 drivers/block/rbd.c clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); rbd_dev 5051 drivers/block/rbd.c static void rbd_dev_update_size(struct rbd_device *rbd_dev) rbd_dev 5060 drivers/block/rbd.c if (test_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags) && rbd_dev 5061 drivers/block/rbd.c !test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags)) { rbd_dev 5062 drivers/block/rbd.c size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE; rbd_dev 5064 drivers/block/rbd.c set_capacity(rbd_dev->disk, size); rbd_dev 5065 drivers/block/rbd.c revalidate_disk(rbd_dev->disk); rbd_dev 5069 drivers/block/rbd.c static int rbd_dev_refresh(struct rbd_device *rbd_dev) rbd_dev 5074 drivers/block/rbd.c down_write(&rbd_dev->header_rwsem); rbd_dev 5075 drivers/block/rbd.c mapping_size = rbd_dev->mapping.size; rbd_dev 5077 drivers/block/rbd.c ret = rbd_dev_header_info(rbd_dev); rbd_dev 5085 drivers/block/rbd.c if (rbd_dev->parent) { rbd_dev 5086 drivers/block/rbd.c ret = rbd_dev_v2_parent_info(rbd_dev); rbd_dev 5091 drivers/block/rbd.c if (rbd_dev->spec->snap_id == CEPH_NOSNAP) { rbd_dev 5092 drivers/block/rbd.c rbd_dev->mapping.size = rbd_dev->header.image_size; rbd_dev 5095 drivers/block/rbd.c rbd_exists_validate(rbd_dev); rbd_dev 5099 drivers/block/rbd.c up_write(&rbd_dev->header_rwsem); rbd_dev 5100 drivers/block/rbd.c if (!ret && mapping_size != rbd_dev->mapping.size) rbd_dev 5101 drivers/block/rbd.c rbd_dev_update_size(rbd_dev); rbd_dev 5120 drivers/block/rbd.c static int rbd_init_disk(struct rbd_device *rbd_dev) rbd_dev 5125 drivers/block/rbd.c rbd_dev->layout.object_size * rbd_dev->layout.stripe_count; rbd_dev 5136 drivers/block/rbd.c rbd_dev->dev_id); rbd_dev 5137 drivers/block/rbd.c disk->major = rbd_dev->major; rbd_dev 5138 drivers/block/rbd.c disk->first_minor = rbd_dev->minor; rbd_dev 5142 drivers/block/rbd.c disk->private_data = rbd_dev; rbd_dev 5144 drivers/block/rbd.c memset(&rbd_dev->tag_set, 0, sizeof(rbd_dev->tag_set)); rbd_dev 5145 drivers/block/rbd.c rbd_dev->tag_set.ops = &rbd_mq_ops; rbd_dev 5146 drivers/block/rbd.c rbd_dev->tag_set.queue_depth = rbd_dev->opts->queue_depth; rbd_dev 5147 drivers/block/rbd.c rbd_dev->tag_set.numa_node = NUMA_NO_NODE; rbd_dev 5148 drivers/block/rbd.c rbd_dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; rbd_dev 5149 drivers/block/rbd.c rbd_dev->tag_set.nr_hw_queues = 1; rbd_dev 5150 drivers/block/rbd.c rbd_dev->tag_set.cmd_size = sizeof(struct work_struct); rbd_dev 5152 drivers/block/rbd.c err = blk_mq_alloc_tag_set(&rbd_dev->tag_set); rbd_dev 5156 drivers/block/rbd.c q = blk_mq_init_queue(&rbd_dev->tag_set); rbd_dev 5169 drivers/block/rbd.c blk_queue_io_min(q, rbd_dev->opts->alloc_size); rbd_dev 5170 drivers/block/rbd.c blk_queue_io_opt(q, rbd_dev->opts->alloc_size); rbd_dev 5172 drivers/block/rbd.c if (rbd_dev->opts->trim) { rbd_dev 5174 drivers/block/rbd.c q->limits.discard_granularity = rbd_dev->opts->alloc_size; rbd_dev 5179 drivers/block/rbd.c if (!ceph_test_opt(rbd_dev->rbd_client->client, NOCRC)) rbd_dev 5188 drivers/block/rbd.c q->queuedata = rbd_dev; rbd_dev 5190 drivers/block/rbd.c rbd_dev->disk = disk; rbd_dev 5194 drivers/block/rbd.c blk_mq_free_tag_set(&rbd_dev->tag_set); rbd_dev 5212 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5215 drivers/block/rbd.c (unsigned long long)rbd_dev->mapping.size); rbd_dev 5225 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5228 drivers/block/rbd.c (unsigned long long)rbd_dev->mapping.features); rbd_dev 5234 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5236 drivers/block/rbd.c if (rbd_dev->major) rbd_dev 5237 drivers/block/rbd.c return sprintf(buf, "%d\n", rbd_dev->major); rbd_dev 5245 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5247 drivers/block/rbd.c return sprintf(buf, "%d\n", rbd_dev->minor); rbd_dev 5253 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5255 drivers/block/rbd.c ceph_client_addr(rbd_dev->rbd_client->client); rbd_dev 5264 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5267 drivers/block/rbd.c ceph_client_gid(rbd_dev->rbd_client->client)); rbd_dev 5273 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5275 drivers/block/rbd.c return sprintf(buf, "%pU\n", &rbd_dev->rbd_client->client->fsid); rbd_dev 5281 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5283 drivers/block/rbd.c return sprintf(buf, "%s\n", rbd_dev->config_info); rbd_dev 5289 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5291 drivers/block/rbd.c return sprintf(buf, "%s\n", rbd_dev->spec->pool_name); rbd_dev 5297 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5300 drivers/block/rbd.c (unsigned long long) rbd_dev->spec->pool_id); rbd_dev 5306 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5308 drivers/block/rbd.c return sprintf(buf, "%s\n", rbd_dev->spec->pool_ns ?: ""); rbd_dev 5314 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5316 drivers/block/rbd.c if (rbd_dev->spec->image_name) rbd_dev 5317 drivers/block/rbd.c return sprintf(buf, "%s\n", rbd_dev->spec->image_name); rbd_dev 5325 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5327 drivers/block/rbd.c return sprintf(buf, "%s\n", rbd_dev->spec->image_id); rbd_dev 5338 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5340 drivers/block/rbd.c return sprintf(buf, "%s\n", rbd_dev->spec->snap_name); rbd_dev 5346 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5348 drivers/block/rbd.c return sprintf(buf, "%llu\n", rbd_dev->spec->snap_id); rbd_dev 5360 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5363 drivers/block/rbd.c if (!rbd_dev->parent) rbd_dev 5366 drivers/block/rbd.c for ( ; rbd_dev->parent; rbd_dev = rbd_dev->parent) { rbd_dev 5367 drivers/block/rbd.c struct rbd_spec *spec = rbd_dev->parent_spec; rbd_dev 5380 drivers/block/rbd.c rbd_dev->parent_overlap); rbd_dev 5391 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5394 drivers/block/rbd.c ret = rbd_dev_refresh(rbd_dev); rbd_dev 5498 drivers/block/rbd.c static void rbd_dev_free(struct rbd_device *rbd_dev) rbd_dev 5500 drivers/block/rbd.c WARN_ON(rbd_dev->watch_state != RBD_WATCH_STATE_UNREGISTERED); rbd_dev 5501 drivers/block/rbd.c WARN_ON(rbd_dev->lock_state != RBD_LOCK_STATE_UNLOCKED); rbd_dev 5503 drivers/block/rbd.c ceph_oid_destroy(&rbd_dev->header_oid); rbd_dev 5504 drivers/block/rbd.c ceph_oloc_destroy(&rbd_dev->header_oloc); rbd_dev 5505 drivers/block/rbd.c kfree(rbd_dev->config_info); rbd_dev 5507 drivers/block/rbd.c rbd_put_client(rbd_dev->rbd_client); rbd_dev 5508 drivers/block/rbd.c rbd_spec_put(rbd_dev->spec); rbd_dev 5509 drivers/block/rbd.c kfree(rbd_dev->opts); rbd_dev 5510 drivers/block/rbd.c kfree(rbd_dev); rbd_dev 5515 drivers/block/rbd.c struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); rbd_dev 5516 drivers/block/rbd.c bool need_put = !!rbd_dev->opts; rbd_dev 5519 drivers/block/rbd.c destroy_workqueue(rbd_dev->task_wq); rbd_dev 5520 drivers/block/rbd.c ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id); rbd_dev 5523 drivers/block/rbd.c rbd_dev_free(rbd_dev); rbd_dev 5537 drivers/block/rbd.c struct rbd_device *rbd_dev; rbd_dev 5539 drivers/block/rbd.c rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL); rbd_dev 5540 drivers/block/rbd.c if (!rbd_dev) rbd_dev 5543 drivers/block/rbd.c spin_lock_init(&rbd_dev->lock); rbd_dev 5544 drivers/block/rbd.c INIT_LIST_HEAD(&rbd_dev->node); rbd_dev 5545 drivers/block/rbd.c init_rwsem(&rbd_dev->header_rwsem); rbd_dev 5547 drivers/block/rbd.c rbd_dev->header.data_pool_id = CEPH_NOPOOL; rbd_dev 5548 drivers/block/rbd.c ceph_oid_init(&rbd_dev->header_oid); rbd_dev 5549 drivers/block/rbd.c rbd_dev->header_oloc.pool = spec->pool_id; rbd_dev 5552 drivers/block/rbd.c rbd_dev->header_oloc.pool_ns = rbd_dev 5557 drivers/block/rbd.c mutex_init(&rbd_dev->watch_mutex); rbd_dev 5558 drivers/block/rbd.c rbd_dev->watch_state = RBD_WATCH_STATE_UNREGISTERED; rbd_dev 5559 drivers/block/rbd.c INIT_DELAYED_WORK(&rbd_dev->watch_dwork, rbd_reregister_watch); rbd_dev 5561 drivers/block/rbd.c init_rwsem(&rbd_dev->lock_rwsem); rbd_dev 5562 drivers/block/rbd.c rbd_dev->lock_state = RBD_LOCK_STATE_UNLOCKED; rbd_dev 5563 drivers/block/rbd.c INIT_WORK(&rbd_dev->acquired_lock_work, rbd_notify_acquired_lock); rbd_dev 5564 drivers/block/rbd.c INIT_WORK(&rbd_dev->released_lock_work, rbd_notify_released_lock); rbd_dev 5565 drivers/block/rbd.c INIT_DELAYED_WORK(&rbd_dev->lock_dwork, rbd_acquire_lock); rbd_dev 5566 drivers/block/rbd.c INIT_WORK(&rbd_dev->unlock_work, rbd_release_lock_work); rbd_dev 5567 drivers/block/rbd.c spin_lock_init(&rbd_dev->lock_lists_lock); rbd_dev 5568 drivers/block/rbd.c INIT_LIST_HEAD(&rbd_dev->acquiring_list); rbd_dev 5569 drivers/block/rbd.c INIT_LIST_HEAD(&rbd_dev->running_list); rbd_dev 5570 drivers/block/rbd.c init_completion(&rbd_dev->acquire_wait); rbd_dev 5571 drivers/block/rbd.c init_completion(&rbd_dev->releasing_wait); rbd_dev 5573 drivers/block/rbd.c spin_lock_init(&rbd_dev->object_map_lock); rbd_dev 5575 drivers/block/rbd.c rbd_dev->dev.bus = &rbd_bus_type; rbd_dev 5576 drivers/block/rbd.c rbd_dev->dev.type = &rbd_device_type; rbd_dev 5577 drivers/block/rbd.c rbd_dev->dev.parent = &rbd_root_dev; rbd_dev 5578 drivers/block/rbd.c device_initialize(&rbd_dev->dev); rbd_dev 5580 drivers/block/rbd.c rbd_dev->rbd_client = rbdc; rbd_dev 5581 drivers/block/rbd.c rbd_dev->spec = spec; rbd_dev 5583 drivers/block/rbd.c return rbd_dev; rbd_dev 5593 drivers/block/rbd.c struct rbd_device *rbd_dev; rbd_dev 5595 drivers/block/rbd.c rbd_dev = __rbd_dev_create(rbdc, spec); rbd_dev 5596 drivers/block/rbd.c if (!rbd_dev) rbd_dev 5599 drivers/block/rbd.c rbd_dev->opts = opts; rbd_dev 5602 drivers/block/rbd.c rbd_dev->dev_id = ida_simple_get(&rbd_dev_id_ida, 0, rbd_dev 5605 drivers/block/rbd.c if (rbd_dev->dev_id < 0) rbd_dev 5608 drivers/block/rbd.c sprintf(rbd_dev->name, RBD_DRV_NAME "%d", rbd_dev->dev_id); rbd_dev 5609 drivers/block/rbd.c rbd_dev->task_wq = alloc_ordered_workqueue("%s-tasks", WQ_MEM_RECLAIM, rbd_dev 5610 drivers/block/rbd.c rbd_dev->name); rbd_dev 5611 drivers/block/rbd.c if (!rbd_dev->task_wq) rbd_dev 5617 drivers/block/rbd.c dout("%s rbd_dev %p dev_id %d\n", __func__, rbd_dev, rbd_dev->dev_id); rbd_dev 5618 drivers/block/rbd.c return rbd_dev; rbd_dev 5621 drivers/block/rbd.c ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id); rbd_dev 5623 drivers/block/rbd.c rbd_dev_free(rbd_dev); rbd_dev 5627 drivers/block/rbd.c static void rbd_dev_destroy(struct rbd_device *rbd_dev) rbd_dev 5629 drivers/block/rbd.c if (rbd_dev) rbd_dev 5630 drivers/block/rbd.c put_device(&rbd_dev->dev); rbd_dev 5638 drivers/block/rbd.c static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 5648 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 5649 drivers/block/rbd.c &rbd_dev->header_oloc, "get_size", rbd_dev 5671 drivers/block/rbd.c static int rbd_dev_v2_image_size(struct rbd_device *rbd_dev) rbd_dev 5673 drivers/block/rbd.c return _rbd_dev_v2_snap_size(rbd_dev, CEPH_NOSNAP, rbd_dev 5674 drivers/block/rbd.c &rbd_dev->header.obj_order, rbd_dev 5675 drivers/block/rbd.c &rbd_dev->header.image_size); rbd_dev 5678 drivers/block/rbd.c static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev) rbd_dev 5691 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 5692 drivers/block/rbd.c &rbd_dev->header_oloc, "get_object_prefix", rbd_dev 5699 drivers/block/rbd.c rbd_dev->header.object_prefix = ceph_extract_encoded_string(&p, rbd_dev 5703 drivers/block/rbd.c if (IS_ERR(rbd_dev->header.object_prefix)) { rbd_dev 5704 drivers/block/rbd.c ret = PTR_ERR(rbd_dev->header.object_prefix); rbd_dev 5705 drivers/block/rbd.c rbd_dev->header.object_prefix = NULL; rbd_dev 5707 drivers/block/rbd.c dout(" object_prefix = %s\n", rbd_dev->header.object_prefix); rbd_dev 5715 drivers/block/rbd.c static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id, rbd_dev 5726 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 5727 drivers/block/rbd.c &rbd_dev->header_oloc, "get_features", rbd_dev 5738 drivers/block/rbd.c rbd_warn(rbd_dev, "image uses unsupported features: 0x%llx", rbd_dev 5753 drivers/block/rbd.c static int rbd_dev_v2_features(struct rbd_device *rbd_dev) rbd_dev 5755 drivers/block/rbd.c return _rbd_dev_v2_snap_features(rbd_dev, CEPH_NOSNAP, rbd_dev 5756 drivers/block/rbd.c &rbd_dev->header.features); rbd_dev 5766 drivers/block/rbd.c static int rbd_dev_v2_get_flags(struct rbd_device *rbd_dev) rbd_dev 5768 drivers/block/rbd.c __le64 snapid = cpu_to_le64(rbd_dev->spec->snap_id); rbd_dev 5772 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 5773 drivers/block/rbd.c &rbd_dev->header_oloc, "get_flags", rbd_dev 5781 drivers/block/rbd.c rbd_dev->object_map_flags = le64_to_cpu(flags); rbd_dev 5830 drivers/block/rbd.c static int __get_parent_info(struct rbd_device *rbd_dev, rbd_dev 5835 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 5840 drivers/block/rbd.c ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, rbd_dev 5852 drivers/block/rbd.c ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, rbd_dev 5873 drivers/block/rbd.c static int __get_parent_info_legacy(struct rbd_device *rbd_dev, rbd_dev 5878 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 5883 drivers/block/rbd.c ret = ceph_osdc_call(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, rbd_dev 5908 drivers/block/rbd.c static int get_parent_info(struct rbd_device *rbd_dev, rbd_dev 5926 drivers/block/rbd.c ceph_encode_64(&p, rbd_dev->spec->snap_id); rbd_dev 5927 drivers/block/rbd.c ret = __get_parent_info(rbd_dev, req_page, reply_page, pii); rbd_dev 5929 drivers/block/rbd.c ret = __get_parent_info_legacy(rbd_dev, req_page, reply_page, rbd_dev 5937 drivers/block/rbd.c static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) rbd_dev 5947 drivers/block/rbd.c ret = get_parent_info(rbd_dev, &pii); rbd_dev 5969 drivers/block/rbd.c if (rbd_dev->parent_overlap) { rbd_dev 5970 drivers/block/rbd.c rbd_dev->parent_overlap = 0; rbd_dev 5971 drivers/block/rbd.c rbd_dev_parent_put(rbd_dev); rbd_dev 5973 drivers/block/rbd.c rbd_dev->disk->disk_name); rbd_dev 5993 drivers/block/rbd.c if (!rbd_dev->parent_spec) { rbd_dev 6003 drivers/block/rbd.c rbd_dev->parent_spec = parent_spec; rbd_dev 6014 drivers/block/rbd.c if (rbd_dev->parent_overlap) rbd_dev 6015 drivers/block/rbd.c rbd_warn(rbd_dev, rbd_dev 6019 drivers/block/rbd.c rbd_warn(rbd_dev, "clone is standalone (overlap 0)"); rbd_dev 6022 drivers/block/rbd.c rbd_dev->parent_overlap = pii.overlap; rbd_dev 6033 drivers/block/rbd.c static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev) rbd_dev 6043 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 6044 drivers/block/rbd.c &rbd_dev->header_oloc, "get_stripe_unit_count", rbd_dev 6053 drivers/block/rbd.c rbd_dev->header.stripe_unit = ceph_decode_64(&p); rbd_dev 6054 drivers/block/rbd.c rbd_dev->header.stripe_count = ceph_decode_64(&p); rbd_dev 6058 drivers/block/rbd.c static int rbd_dev_v2_data_pool(struct rbd_device *rbd_dev) rbd_dev 6063 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 6064 drivers/block/rbd.c &rbd_dev->header_oloc, "get_data_pool", rbd_dev 6071 drivers/block/rbd.c rbd_dev->header.data_pool_id = le64_to_cpu(data_pool_id); rbd_dev 6072 drivers/block/rbd.c WARN_ON(rbd_dev->header.data_pool_id == CEPH_NOPOOL); rbd_dev 6076 drivers/block/rbd.c static char *rbd_dev_image_name(struct rbd_device *rbd_dev) rbd_dev 6089 drivers/block/rbd.c rbd_assert(!rbd_dev->spec->image_name); rbd_dev 6091 drivers/block/rbd.c len = strlen(rbd_dev->spec->image_id); rbd_dev 6099 drivers/block/rbd.c ceph_encode_string(&p, end, rbd_dev->spec->image_id, (u32)len); rbd_dev 6107 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &oid, &rbd_dev->header_oloc, rbd_dev 6127 drivers/block/rbd.c static u64 rbd_v1_snap_id_by_name(struct rbd_device *rbd_dev, const char *name) rbd_dev 6129 drivers/block/rbd.c struct ceph_snap_context *snapc = rbd_dev->header.snapc; rbd_dev 6135 drivers/block/rbd.c snap_name = rbd_dev->header.snap_names; rbd_dev 6145 drivers/block/rbd.c static u64 rbd_v2_snap_id_by_name(struct rbd_device *rbd_dev, const char *name) rbd_dev 6147 drivers/block/rbd.c struct ceph_snap_context *snapc = rbd_dev->header.snapc; rbd_dev 6156 drivers/block/rbd.c snap_name = rbd_dev_v2_snap_name(rbd_dev, snap_id); rbd_dev 6174 drivers/block/rbd.c static u64 rbd_snap_id_by_name(struct rbd_device *rbd_dev, const char *name) rbd_dev 6176 drivers/block/rbd.c if (rbd_dev->image_format == 1) rbd_dev 6177 drivers/block/rbd.c return rbd_v1_snap_id_by_name(rbd_dev, name); rbd_dev 6179 drivers/block/rbd.c return rbd_v2_snap_id_by_name(rbd_dev, name); rbd_dev 6185 drivers/block/rbd.c static int rbd_spec_fill_snap_id(struct rbd_device *rbd_dev) rbd_dev 6187 drivers/block/rbd.c struct rbd_spec *spec = rbd_dev->spec; rbd_dev 6196 drivers/block/rbd.c snap_id = rbd_snap_id_by_name(rbd_dev, spec->snap_name); rbd_dev 6214 drivers/block/rbd.c static int rbd_spec_fill_names(struct rbd_device *rbd_dev) rbd_dev 6216 drivers/block/rbd.c struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; rbd_dev 6217 drivers/block/rbd.c struct rbd_spec *spec = rbd_dev->spec; rbd_dev 6231 drivers/block/rbd.c rbd_warn(rbd_dev, "no pool with id %llu", spec->pool_id); rbd_dev 6240 drivers/block/rbd.c image_name = rbd_dev_image_name(rbd_dev); rbd_dev 6242 drivers/block/rbd.c rbd_warn(rbd_dev, "unable to get image name"); rbd_dev 6246 drivers/block/rbd.c snap_name = rbd_snap_name(rbd_dev, spec->snap_id); rbd_dev 6264 drivers/block/rbd.c static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev) rbd_dev 6288 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 6289 drivers/block/rbd.c &rbd_dev->header_oloc, "get_snapcontext", rbd_dev 6325 drivers/block/rbd.c ceph_put_snap_context(rbd_dev->header.snapc); rbd_dev 6326 drivers/block/rbd.c rbd_dev->header.snapc = snapc; rbd_dev 6336 drivers/block/rbd.c static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, rbd_dev 6353 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid, rbd_dev 6354 drivers/block/rbd.c &rbd_dev->header_oloc, "get_snapshot_name", rbd_dev 6376 drivers/block/rbd.c static int rbd_dev_v2_header_info(struct rbd_device *rbd_dev) rbd_dev 6378 drivers/block/rbd.c bool first_time = rbd_dev->header.object_prefix == NULL; rbd_dev 6381 drivers/block/rbd.c ret = rbd_dev_v2_image_size(rbd_dev); rbd_dev 6386 drivers/block/rbd.c ret = rbd_dev_v2_header_onetime(rbd_dev); rbd_dev 6391 drivers/block/rbd.c ret = rbd_dev_v2_snap_context(rbd_dev); rbd_dev 6393 drivers/block/rbd.c kfree(rbd_dev->header.object_prefix); rbd_dev 6394 drivers/block/rbd.c rbd_dev->header.object_prefix = NULL; rbd_dev 6400 drivers/block/rbd.c static int rbd_dev_header_info(struct rbd_device *rbd_dev) rbd_dev 6402 drivers/block/rbd.c rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); rbd_dev 6404 drivers/block/rbd.c if (rbd_dev->image_format == 1) rbd_dev 6405 drivers/block/rbd.c return rbd_dev_v1_header_info(rbd_dev); rbd_dev 6407 drivers/block/rbd.c return rbd_dev_v2_header_info(rbd_dev); rbd_dev 6614 drivers/block/rbd.c static void rbd_dev_image_unlock(struct rbd_device *rbd_dev) rbd_dev 6616 drivers/block/rbd.c down_write(&rbd_dev->lock_rwsem); rbd_dev 6617 drivers/block/rbd.c if (__rbd_is_lock_owner(rbd_dev)) rbd_dev 6618 drivers/block/rbd.c __rbd_release_lock(rbd_dev); rbd_dev 6619 drivers/block/rbd.c up_write(&rbd_dev->lock_rwsem); rbd_dev 6627 drivers/block/rbd.c static int rbd_add_acquire_lock(struct rbd_device *rbd_dev) rbd_dev 6631 drivers/block/rbd.c if (!(rbd_dev->header.features & RBD_FEATURE_EXCLUSIVE_LOCK)) { rbd_dev 6632 drivers/block/rbd.c if (!rbd_dev->opts->exclusive && !rbd_dev->opts->lock_on_read) rbd_dev 6635 drivers/block/rbd.c rbd_warn(rbd_dev, "exclusive-lock feature is not enabled"); rbd_dev 6639 drivers/block/rbd.c if (rbd_dev->spec->snap_id != CEPH_NOSNAP) rbd_dev 6642 drivers/block/rbd.c rbd_assert(!rbd_is_lock_owner(rbd_dev)); rbd_dev 6643 drivers/block/rbd.c queue_delayed_work(rbd_dev->task_wq, &rbd_dev->lock_dwork, 0); rbd_dev 6644 drivers/block/rbd.c ret = wait_for_completion_killable_timeout(&rbd_dev->acquire_wait, rbd_dev 6645 drivers/block/rbd.c ceph_timeout_jiffies(rbd_dev->opts->lock_timeout)); rbd_dev 6647 drivers/block/rbd.c ret = rbd_dev->acquire_err; rbd_dev 6649 drivers/block/rbd.c cancel_delayed_work_sync(&rbd_dev->lock_dwork); rbd_dev 6655 drivers/block/rbd.c rbd_warn(rbd_dev, "failed to acquire exclusive lock: %ld", ret); rbd_dev 6663 drivers/block/rbd.c rbd_assert(!rbd_dev->opts->exclusive || rbd_is_lock_owner(rbd_dev)); rbd_dev 6681 drivers/block/rbd.c static int rbd_dev_image_id(struct rbd_device *rbd_dev) rbd_dev 6695 drivers/block/rbd.c if (rbd_dev->spec->image_id) { rbd_dev 6696 drivers/block/rbd.c rbd_dev->image_format = *rbd_dev->spec->image_id ? 2 : 1; rbd_dev 6706 drivers/block/rbd.c rbd_dev->spec->image_name); rbd_dev 6722 drivers/block/rbd.c ret = rbd_obj_method_sync(rbd_dev, &oid, &rbd_dev->header_oloc, rbd_dev 6730 drivers/block/rbd.c rbd_dev->image_format = 1; rbd_dev 6738 drivers/block/rbd.c rbd_dev->image_format = 2; rbd_dev 6742 drivers/block/rbd.c rbd_dev->spec->image_id = image_id; rbd_dev 6755 drivers/block/rbd.c static void rbd_dev_unprobe(struct rbd_device *rbd_dev) rbd_dev 6759 drivers/block/rbd.c rbd_dev_parent_put(rbd_dev); rbd_dev 6760 drivers/block/rbd.c rbd_object_map_free(rbd_dev); rbd_dev 6761 drivers/block/rbd.c rbd_dev_mapping_clear(rbd_dev); rbd_dev 6765 drivers/block/rbd.c header = &rbd_dev->header; rbd_dev 6773 drivers/block/rbd.c static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev) rbd_dev 6777 drivers/block/rbd.c ret = rbd_dev_v2_object_prefix(rbd_dev); rbd_dev 6785 drivers/block/rbd.c ret = rbd_dev_v2_features(rbd_dev); rbd_dev 6791 drivers/block/rbd.c if (rbd_dev->header.features & RBD_FEATURE_STRIPINGV2) { rbd_dev 6792 drivers/block/rbd.c ret = rbd_dev_v2_striping_info(rbd_dev); rbd_dev 6797 drivers/block/rbd.c if (rbd_dev->header.features & RBD_FEATURE_DATA_POOL) { rbd_dev 6798 drivers/block/rbd.c ret = rbd_dev_v2_data_pool(rbd_dev); rbd_dev 6803 drivers/block/rbd.c rbd_init_layout(rbd_dev); rbd_dev 6807 drivers/block/rbd.c rbd_dev->header.features = 0; rbd_dev 6808 drivers/block/rbd.c kfree(rbd_dev->header.object_prefix); rbd_dev 6809 drivers/block/rbd.c rbd_dev->header.object_prefix = NULL; rbd_dev 6818 drivers/block/rbd.c static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth) rbd_dev 6823 drivers/block/rbd.c if (!rbd_dev->parent_spec) rbd_dev 6832 drivers/block/rbd.c parent = __rbd_dev_create(rbd_dev->rbd_client, rbd_dev->parent_spec); rbd_dev 6842 drivers/block/rbd.c __rbd_get_client(rbd_dev->rbd_client); rbd_dev 6843 drivers/block/rbd.c rbd_spec_get(rbd_dev->parent_spec); rbd_dev 6849 drivers/block/rbd.c rbd_dev->parent = parent; rbd_dev 6850 drivers/block/rbd.c atomic_set(&rbd_dev->parent_ref, 1); rbd_dev 6854 drivers/block/rbd.c rbd_dev_unparent(rbd_dev); rbd_dev 6859 drivers/block/rbd.c static void rbd_dev_device_release(struct rbd_device *rbd_dev) rbd_dev 6861 drivers/block/rbd.c clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); rbd_dev 6862 drivers/block/rbd.c rbd_free_disk(rbd_dev); rbd_dev 6864 drivers/block/rbd.c unregister_blkdev(rbd_dev->major, rbd_dev->name); rbd_dev 6871 drivers/block/rbd.c static int rbd_dev_device_setup(struct rbd_device *rbd_dev) rbd_dev 6878 drivers/block/rbd.c ret = register_blkdev(0, rbd_dev->name); rbd_dev 6882 drivers/block/rbd.c rbd_dev->major = ret; rbd_dev 6883 drivers/block/rbd.c rbd_dev->minor = 0; rbd_dev 6885 drivers/block/rbd.c rbd_dev->major = rbd_major; rbd_dev 6886 drivers/block/rbd.c rbd_dev->minor = rbd_dev_id_to_minor(rbd_dev->dev_id); rbd_dev 6891 drivers/block/rbd.c ret = rbd_init_disk(rbd_dev); rbd_dev 6895 drivers/block/rbd.c set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); rbd_dev 6896 drivers/block/rbd.c set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only); rbd_dev 6898 drivers/block/rbd.c ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id); rbd_dev 6902 drivers/block/rbd.c set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); rbd_dev 6903 drivers/block/rbd.c up_write(&rbd_dev->header_rwsem); rbd_dev 6907 drivers/block/rbd.c rbd_free_disk(rbd_dev); rbd_dev 6910 drivers/block/rbd.c unregister_blkdev(rbd_dev->major, rbd_dev->name); rbd_dev 6912 drivers/block/rbd.c up_write(&rbd_dev->header_rwsem); rbd_dev 6916 drivers/block/rbd.c static int rbd_dev_header_name(struct rbd_device *rbd_dev) rbd_dev 6918 drivers/block/rbd.c struct rbd_spec *spec = rbd_dev->spec; rbd_dev 6923 drivers/block/rbd.c rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); rbd_dev 6924 drivers/block/rbd.c if (rbd_dev->image_format == 1) rbd_dev 6925 drivers/block/rbd.c ret = ceph_oid_aprintf(&rbd_dev->header_oid, GFP_KERNEL, "%s%s", rbd_dev 6928 drivers/block/rbd.c ret = ceph_oid_aprintf(&rbd_dev->header_oid, GFP_KERNEL, "%s%s", rbd_dev 6934 drivers/block/rbd.c static void rbd_dev_image_release(struct rbd_device *rbd_dev) rbd_dev 6936 drivers/block/rbd.c if (rbd_dev->opts) rbd_dev 6937 drivers/block/rbd.c rbd_unregister_watch(rbd_dev); rbd_dev 6939 drivers/block/rbd.c rbd_dev_unprobe(rbd_dev); rbd_dev 6940 drivers/block/rbd.c rbd_dev->image_format = 0; rbd_dev 6941 drivers/block/rbd.c kfree(rbd_dev->spec->image_id); rbd_dev 6942 drivers/block/rbd.c rbd_dev->spec->image_id = NULL; rbd_dev 6954 drivers/block/rbd.c static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth) rbd_dev 6964 drivers/block/rbd.c ret = rbd_dev_image_id(rbd_dev); rbd_dev 6968 drivers/block/rbd.c ret = rbd_dev_header_name(rbd_dev); rbd_dev 6973 drivers/block/rbd.c ret = rbd_register_watch(rbd_dev); rbd_dev 6977 drivers/block/rbd.c rbd_dev->spec->pool_name, rbd_dev 6978 drivers/block/rbd.c rbd_dev->spec->pool_ns ?: "", rbd_dev 6979 drivers/block/rbd.c rbd_dev->spec->pool_ns ? "/" : "", rbd_dev 6980 drivers/block/rbd.c rbd_dev->spec->image_name); rbd_dev 6986 drivers/block/rbd.c down_write(&rbd_dev->header_rwsem); rbd_dev 6988 drivers/block/rbd.c ret = rbd_dev_header_info(rbd_dev); rbd_dev 6999 drivers/block/rbd.c ret = rbd_spec_fill_snap_id(rbd_dev); rbd_dev 7001 drivers/block/rbd.c ret = rbd_spec_fill_names(rbd_dev); rbd_dev 7005 drivers/block/rbd.c rbd_dev->spec->pool_name, rbd_dev 7006 drivers/block/rbd.c rbd_dev->spec->pool_ns ?: "", rbd_dev 7007 drivers/block/rbd.c rbd_dev->spec->pool_ns ? "/" : "", rbd_dev 7008 drivers/block/rbd.c rbd_dev->spec->image_name, rbd_dev 7009 drivers/block/rbd.c rbd_dev->spec->snap_name); rbd_dev 7013 drivers/block/rbd.c ret = rbd_dev_mapping_set(rbd_dev); rbd_dev 7017 drivers/block/rbd.c if (rbd_dev->spec->snap_id != CEPH_NOSNAP && rbd_dev 7018 drivers/block/rbd.c (rbd_dev->header.features & RBD_FEATURE_OBJECT_MAP)) { rbd_dev 7019 drivers/block/rbd.c ret = rbd_object_map_load(rbd_dev); rbd_dev 7024 drivers/block/rbd.c if (rbd_dev->header.features & RBD_FEATURE_LAYERING) { rbd_dev 7025 drivers/block/rbd.c ret = rbd_dev_v2_parent_info(rbd_dev); rbd_dev 7030 drivers/block/rbd.c ret = rbd_dev_probe_parent(rbd_dev, depth); rbd_dev 7035 drivers/block/rbd.c rbd_dev->image_format, rbd_dev->header_oid.name); rbd_dev 7040 drivers/block/rbd.c up_write(&rbd_dev->header_rwsem); rbd_dev 7042 drivers/block/rbd.c rbd_unregister_watch(rbd_dev); rbd_dev 7043 drivers/block/rbd.c rbd_dev_unprobe(rbd_dev); rbd_dev 7045 drivers/block/rbd.c rbd_dev->image_format = 0; rbd_dev 7046 drivers/block/rbd.c kfree(rbd_dev->spec->image_id); rbd_dev 7047 drivers/block/rbd.c rbd_dev->spec->image_id = NULL; rbd_dev 7055 drivers/block/rbd.c struct rbd_device *rbd_dev = NULL; rbd_dev 7085 drivers/block/rbd.c rbd_dev = rbd_dev_create(rbdc, spec, rbd_opts); rbd_dev 7086 drivers/block/rbd.c if (!rbd_dev) { rbd_dev 7094 drivers/block/rbd.c rbd_dev->config_info = kstrdup(buf, GFP_KERNEL); rbd_dev 7095 drivers/block/rbd.c if (!rbd_dev->config_info) { rbd_dev 7100 drivers/block/rbd.c rc = rbd_dev_image_probe(rbd_dev, 0); rbd_dev 7105 drivers/block/rbd.c if (rbd_dev->spec->snap_id != CEPH_NOSNAP) rbd_dev 7106 drivers/block/rbd.c rbd_dev->opts->read_only = true; rbd_dev 7108 drivers/block/rbd.c if (rbd_dev->opts->alloc_size > rbd_dev->layout.object_size) { rbd_dev 7109 drivers/block/rbd.c rbd_warn(rbd_dev, "alloc_size adjusted to %u", rbd_dev 7110 drivers/block/rbd.c rbd_dev->layout.object_size); rbd_dev 7111 drivers/block/rbd.c rbd_dev->opts->alloc_size = rbd_dev->layout.object_size; rbd_dev 7114 drivers/block/rbd.c rc = rbd_dev_device_setup(rbd_dev); rbd_dev 7118 drivers/block/rbd.c rc = rbd_add_acquire_lock(rbd_dev); rbd_dev 7124 drivers/block/rbd.c rc = device_add(&rbd_dev->dev); rbd_dev 7128 drivers/block/rbd.c add_disk(rbd_dev->disk); rbd_dev 7130 drivers/block/rbd.c blk_put_queue(rbd_dev->disk->queue); rbd_dev 7133 drivers/block/rbd.c list_add_tail(&rbd_dev->node, &rbd_dev_list); rbd_dev 7136 drivers/block/rbd.c pr_info("%s: capacity %llu features 0x%llx\n", rbd_dev->disk->disk_name, rbd_dev 7137 drivers/block/rbd.c (unsigned long long)get_capacity(rbd_dev->disk) << SECTOR_SHIFT, rbd_dev 7138 drivers/block/rbd.c rbd_dev->header.features); rbd_dev 7145 drivers/block/rbd.c rbd_dev_image_unlock(rbd_dev); rbd_dev 7146 drivers/block/rbd.c rbd_dev_device_release(rbd_dev); rbd_dev 7148 drivers/block/rbd.c rbd_dev_image_release(rbd_dev); rbd_dev 7150 drivers/block/rbd.c rbd_dev_destroy(rbd_dev); rbd_dev 7173 drivers/block/rbd.c static void rbd_dev_remove_parent(struct rbd_device *rbd_dev) rbd_dev 7175 drivers/block/rbd.c while (rbd_dev->parent) { rbd_dev 7176 drivers/block/rbd.c struct rbd_device *first = rbd_dev; rbd_dev 7204 drivers/block/rbd.c struct rbd_device *rbd_dev = NULL; rbd_dev 7230 drivers/block/rbd.c rbd_dev = list_entry(tmp, struct rbd_device, node); rbd_dev 7231 drivers/block/rbd.c if (rbd_dev->dev_id == dev_id) { rbd_dev 7237 drivers/block/rbd.c spin_lock_irq(&rbd_dev->lock); rbd_dev 7238 drivers/block/rbd.c if (rbd_dev->open_count && !force) rbd_dev 7241 drivers/block/rbd.c &rbd_dev->flags)) rbd_dev 7243 drivers/block/rbd.c spin_unlock_irq(&rbd_dev->lock); rbd_dev 7254 drivers/block/rbd.c blk_mq_freeze_queue(rbd_dev->disk->queue); rbd_dev 7255 drivers/block/rbd.c blk_set_queue_dying(rbd_dev->disk->queue); rbd_dev 7258 drivers/block/rbd.c del_gendisk(rbd_dev->disk); rbd_dev 7260 drivers/block/rbd.c list_del_init(&rbd_dev->node); rbd_dev 7262 drivers/block/rbd.c device_del(&rbd_dev->dev); rbd_dev 7264 drivers/block/rbd.c rbd_dev_image_unlock(rbd_dev); rbd_dev 7265 drivers/block/rbd.c rbd_dev_device_release(rbd_dev); rbd_dev 7266 drivers/block/rbd.c rbd_dev_image_release(rbd_dev); rbd_dev 7267 drivers/block/rbd.c rbd_dev_destroy(rbd_dev);