Commit 812164f8c3f6f5348aa69003a2f81775c2872ac0
Committed by
Sage Weil
1 parent
4f0dcb10cf
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ceph: use ceph_create_snap_context()
Now that we have a library routine to create snap contexts, use it. This is part of: http://tracker.ceph.com/issues/4857 Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Showing 2 changed files with 7 additions and 37 deletions Side-by-side Diff
drivers/block/rbd.c
... | ... | @@ -672,35 +672,6 @@ |
672 | 672 | kfree(rbdc); |
673 | 673 | } |
674 | 674 | |
675 | -/* Caller has to fill in snapc->seq and snapc->snaps[0..snap_count-1] */ | |
676 | - | |
677 | -static struct ceph_snap_context *rbd_snap_context_create(u32 snap_count) | |
678 | -{ | |
679 | - struct ceph_snap_context *snapc; | |
680 | - size_t size; | |
681 | - | |
682 | - size = sizeof (struct ceph_snap_context); | |
683 | - size += snap_count * sizeof (snapc->snaps[0]); | |
684 | - snapc = kzalloc(size, GFP_KERNEL); | |
685 | - if (!snapc) | |
686 | - return NULL; | |
687 | - | |
688 | - atomic_set(&snapc->nref, 1); | |
689 | - snapc->num_snaps = snap_count; | |
690 | - | |
691 | - return snapc; | |
692 | -} | |
693 | - | |
694 | -static inline void rbd_snap_context_get(struct ceph_snap_context *snapc) | |
695 | -{ | |
696 | - (void)ceph_get_snap_context(snapc); | |
697 | -} | |
698 | - | |
699 | -static inline void rbd_snap_context_put(struct ceph_snap_context *snapc) | |
700 | -{ | |
701 | - ceph_put_snap_context(snapc); | |
702 | -} | |
703 | - | |
704 | 675 | /* |
705 | 676 | * Drop reference to ceph client node. If it's not referenced anymore, release |
706 | 677 | * it. |
... | ... | @@ -820,7 +791,7 @@ |
820 | 791 | |
821 | 792 | header->image_size = le64_to_cpu(ondisk->image_size); |
822 | 793 | |
823 | - header->snapc = rbd_snap_context_create(snap_count); | |
794 | + header->snapc = ceph_create_snap_context(snap_count, GFP_KERNEL); | |
824 | 795 | if (!header->snapc) |
825 | 796 | goto out_err; |
826 | 797 | header->snapc->seq = le64_to_cpu(ondisk->snap_seq); |
... | ... | @@ -1753,7 +1724,7 @@ |
1753 | 1724 | |
1754 | 1725 | if (write_request) { |
1755 | 1726 | down_read(&rbd_dev->header_rwsem); |
1756 | - rbd_snap_context_get(rbd_dev->header.snapc); | |
1727 | + ceph_get_snap_context(rbd_dev->header.snapc); | |
1757 | 1728 | up_read(&rbd_dev->header_rwsem); |
1758 | 1729 | } |
1759 | 1730 | |
... | ... | @@ -1805,7 +1776,7 @@ |
1805 | 1776 | rbd_assert(img_request->obj_request_count == 0); |
1806 | 1777 | |
1807 | 1778 | if (img_request_write_test(img_request)) |
1808 | - rbd_snap_context_put(img_request->snapc); | |
1779 | + ceph_put_snap_context(img_request->snapc); | |
1809 | 1780 | |
1810 | 1781 | if (img_request_child_test(img_request)) |
1811 | 1782 | rbd_obj_request_put(img_request->obj_request); |
... | ... | @@ -3071,7 +3042,7 @@ |
3071 | 3042 | kfree(rbd_dev->header.snap_sizes); |
3072 | 3043 | kfree(rbd_dev->header.snap_names); |
3073 | 3044 | /* osd requests may still refer to snapc */ |
3074 | - rbd_snap_context_put(rbd_dev->header.snapc); | |
3045 | + ceph_put_snap_context(rbd_dev->header.snapc); | |
3075 | 3046 | |
3076 | 3047 | if (hver) |
3077 | 3048 | *hver = h.obj_version; |
... | ... | @@ -3914,7 +3885,7 @@ |
3914 | 3885 | goto out; |
3915 | 3886 | ret = 0; |
3916 | 3887 | |
3917 | - snapc = rbd_snap_context_create(snap_count); | |
3888 | + snapc = ceph_create_snap_context(snap_count, GFP_KERNEL); | |
3918 | 3889 | if (!snapc) { |
3919 | 3890 | ret = -ENOMEM; |
3920 | 3891 | goto out; |
... | ... | @@ -4590,7 +4561,7 @@ |
4590 | 4561 | /* Free dynamic fields from the header, then zero it out */ |
4591 | 4562 | |
4592 | 4563 | header = &rbd_dev->header; |
4593 | - rbd_snap_context_put(header->snapc); | |
4564 | + ceph_put_snap_context(header->snapc); | |
4594 | 4565 | kfree(header->snap_sizes); |
4595 | 4566 | kfree(header->snap_names); |
4596 | 4567 | kfree(header->object_prefix); |
fs/ceph/snap.c
... | ... | @@ -332,10 +332,9 @@ |
332 | 332 | err = -ENOMEM; |
333 | 333 | if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) |
334 | 334 | goto fail; |
335 | - snapc = kzalloc(sizeof(*snapc) + num*sizeof(u64), GFP_NOFS); | |
335 | + snapc = ceph_create_snap_context(num, GFP_NOFS); | |
336 | 336 | if (!snapc) |
337 | 337 | goto fail; |
338 | - atomic_set(&snapc->nref, 1); | |
339 | 338 | |
340 | 339 | /* build (reverse sorted) snap vector */ |
341 | 340 | num = 0; |