diff options
author | Yan, Zheng <zyan@redhat.com> | 2016-02-03 08:24:49 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-07-27 20:55:36 -0400 |
commit | 7627151ea30bce2051e3cb27d7bb2c30083f86a5 (patch) | |
tree | 8a4c9422b30c3e50eb76923c746747f4e09d0bb5 /net | |
parent | 22748f9d617b8cd0a915c3a4c656c7232645b3b5 (diff) |
libceph: define new ceph_file_layout structure
Define new ceph_file_layout structure and rename old ceph_file_layout
to ceph_file_layout_legacy. This is preparation for adding namespace
to ceph_file_layout structure.
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/ceph_fs.c | 30 | ||||
-rw-r--r-- | net/ceph/osd_client.c | 4 | ||||
-rw-r--r-- | net/ceph/osdmap.c | 6 |
3 files changed, 32 insertions, 8 deletions
diff --git a/net/ceph/ceph_fs.c b/net/ceph/ceph_fs.c index 41466ccb972a..7d54e944de5e 100644 --- a/net/ceph/ceph_fs.c +++ b/net/ceph/ceph_fs.c | |||
@@ -9,9 +9,9 @@ | |||
9 | */ | 9 | */ |
10 | int ceph_file_layout_is_valid(const struct ceph_file_layout *layout) | 10 | int ceph_file_layout_is_valid(const struct ceph_file_layout *layout) |
11 | { | 11 | { |
12 | __u32 su = le32_to_cpu(layout->fl_stripe_unit); | 12 | __u32 su = layout->stripe_unit; |
13 | __u32 sc = le32_to_cpu(layout->fl_stripe_count); | 13 | __u32 sc = layout->stripe_count; |
14 | __u32 os = le32_to_cpu(layout->fl_object_size); | 14 | __u32 os = layout->object_size; |
15 | 15 | ||
16 | /* stripe unit, object size must be non-zero, 64k increment */ | 16 | /* stripe unit, object size must be non-zero, 64k increment */ |
17 | if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1))) | 17 | if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1))) |
@@ -27,6 +27,30 @@ int ceph_file_layout_is_valid(const struct ceph_file_layout *layout) | |||
27 | return 1; | 27 | return 1; |
28 | } | 28 | } |
29 | 29 | ||
30 | void ceph_file_layout_from_legacy(struct ceph_file_layout *fl, | ||
31 | struct ceph_file_layout_legacy *legacy) | ||
32 | { | ||
33 | fl->stripe_unit = le32_to_cpu(legacy->fl_stripe_unit); | ||
34 | fl->stripe_count = le32_to_cpu(legacy->fl_stripe_count); | ||
35 | fl->object_size = le32_to_cpu(legacy->fl_object_size); | ||
36 | fl->pool_id = le32_to_cpu(legacy->fl_pg_pool); | ||
37 | if (fl->pool_id == 0) | ||
38 | fl->pool_id = -1; | ||
39 | } | ||
40 | EXPORT_SYMBOL(ceph_file_layout_from_legacy); | ||
41 | |||
42 | void ceph_file_layout_to_legacy(struct ceph_file_layout *fl, | ||
43 | struct ceph_file_layout_legacy *legacy) | ||
44 | { | ||
45 | legacy->fl_stripe_unit = cpu_to_le32(fl->stripe_unit); | ||
46 | legacy->fl_stripe_count = cpu_to_le32(fl->stripe_count); | ||
47 | legacy->fl_object_size = cpu_to_le32(fl->object_size); | ||
48 | if (fl->pool_id >= 0) | ||
49 | legacy->fl_pg_pool = cpu_to_le32(fl->pool_id); | ||
50 | else | ||
51 | legacy->fl_pg_pool = 0; | ||
52 | } | ||
53 | EXPORT_SYMBOL(ceph_file_layout_to_legacy); | ||
30 | 54 | ||
31 | int ceph_flags_to_mode(int flags) | 55 | int ceph_flags_to_mode(int flags) |
32 | { | 56 | { |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 89469592076c..23efcac80072 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -932,7 +932,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
932 | if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) { | 932 | if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) { |
933 | osd_req_op_init(req, which, opcode, 0); | 933 | osd_req_op_init(req, which, opcode, 0); |
934 | } else { | 934 | } else { |
935 | u32 object_size = le32_to_cpu(layout->fl_object_size); | 935 | u32 object_size = layout->object_size; |
936 | u32 object_base = off - objoff; | 936 | u32 object_base = off - objoff; |
937 | if (!(truncate_seq == 1 && truncate_size == -1ULL)) { | 937 | if (!(truncate_seq == 1 && truncate_size == -1ULL)) { |
938 | if (truncate_size <= object_base) { | 938 | if (truncate_size <= object_base) { |
@@ -948,7 +948,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
948 | } | 948 | } |
949 | 949 | ||
950 | req->r_flags = flags; | 950 | req->r_flags = flags; |
951 | req->r_base_oloc.pool = ceph_file_layout_pg_pool(*layout); | 951 | req->r_base_oloc.pool = layout->pool_id; |
952 | ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum); | 952 | ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum); |
953 | 953 | ||
954 | req->r_snapid = vino.snap; | 954 | req->r_snapid = vino.snap; |
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 7e480bf75bcf..5947b2e9fb8e 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -1770,9 +1770,9 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout, | |||
1770 | u64 *ono, | 1770 | u64 *ono, |
1771 | u64 *oxoff, u64 *oxlen) | 1771 | u64 *oxoff, u64 *oxlen) |
1772 | { | 1772 | { |
1773 | u32 osize = le32_to_cpu(layout->fl_object_size); | 1773 | u32 osize = layout->object_size; |
1774 | u32 su = le32_to_cpu(layout->fl_stripe_unit); | 1774 | u32 su = layout->stripe_unit; |
1775 | u32 sc = le32_to_cpu(layout->fl_stripe_count); | 1775 | u32 sc = layout->stripe_count; |
1776 | u32 bl, stripeno, stripepos, objsetno; | 1776 | u32 bl, stripeno, stripepos, objsetno; |
1777 | u32 su_per_object; | 1777 | u32 su_per_object; |
1778 | u64 t, su_offset; | 1778 | u64 t, su_offset; |