diff options
author | Alex Elder <elder@inktank.com> | 2013-04-03 02:28:58 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:09 -0400 |
commit | 23c08a9cb2d832cd1d2b7ccdb54d0ab7b8518933 (patch) | |
tree | f01927eae415d71c0a984c1f2e87fa923f51e6ec /net/ceph | |
parent | c54d47bfadce7059af0774d80b2b3faaea4afd28 (diff) |
libceph: define ceph_osd_data_length()
One more osd data helper, which returns the length of the
data item, regardless of its type.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osd_client.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index b399e8a18f2b..e197c5c0b3a2 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -117,6 +117,25 @@ void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data, | |||
117 | EXPORT_SYMBOL(ceph_osd_data_bio_init); | 117 | EXPORT_SYMBOL(ceph_osd_data_bio_init); |
118 | #endif /* CONFIG_BLOCK */ | 118 | #endif /* CONFIG_BLOCK */ |
119 | 119 | ||
120 | static u64 ceph_osd_data_length(struct ceph_osd_data *osd_data) | ||
121 | { | ||
122 | switch (osd_data->type) { | ||
123 | case CEPH_OSD_DATA_TYPE_NONE: | ||
124 | return 0; | ||
125 | case CEPH_OSD_DATA_TYPE_PAGES: | ||
126 | return osd_data->length; | ||
127 | case CEPH_OSD_DATA_TYPE_PAGELIST: | ||
128 | return (u64)osd_data->pagelist->length; | ||
129 | #ifdef CONFIG_BLOCK | ||
130 | case CEPH_OSD_DATA_TYPE_BIO: | ||
131 | return (u64)osd_data->bio_length; | ||
132 | #endif /* CONFIG_BLOCK */ | ||
133 | default: | ||
134 | WARN(true, "unrecognized data type %d\n", (int)osd_data->type); | ||
135 | return 0; | ||
136 | } | ||
137 | } | ||
138 | |||
120 | static void ceph_osd_data_release(struct ceph_osd_data *osd_data) | 139 | static void ceph_osd_data_release(struct ceph_osd_data *osd_data) |
121 | { | 140 | { |
122 | if (osd_data->type != CEPH_OSD_DATA_TYPE_PAGES) | 141 | if (osd_data->type != CEPH_OSD_DATA_TYPE_PAGES) |
@@ -1887,17 +1906,19 @@ bad: | |||
1887 | static void ceph_osdc_msg_data_set(struct ceph_msg *msg, | 1906 | static void ceph_osdc_msg_data_set(struct ceph_msg *msg, |
1888 | struct ceph_osd_data *osd_data) | 1907 | struct ceph_osd_data *osd_data) |
1889 | { | 1908 | { |
1909 | u64 length = ceph_osd_data_length(osd_data); | ||
1910 | |||
1890 | if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) { | 1911 | if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) { |
1891 | BUG_ON(osd_data->length > (u64) SIZE_MAX); | 1912 | BUG_ON(length > (u64) SIZE_MAX); |
1892 | if (osd_data->length) | 1913 | if (length) |
1893 | ceph_msg_data_set_pages(msg, osd_data->pages, | 1914 | ceph_msg_data_set_pages(msg, osd_data->pages, |
1894 | osd_data->length, osd_data->alignment); | 1915 | length, osd_data->alignment); |
1895 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { | 1916 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) { |
1896 | BUG_ON(!osd_data->pagelist->length); | 1917 | BUG_ON(!length); |
1897 | ceph_msg_data_set_pagelist(msg, osd_data->pagelist); | 1918 | ceph_msg_data_set_pagelist(msg, osd_data->pagelist); |
1898 | #ifdef CONFIG_BLOCK | 1919 | #ifdef CONFIG_BLOCK |
1899 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { | 1920 | } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) { |
1900 | ceph_msg_data_set_bio(msg, osd_data->bio, osd_data->bio_length); | 1921 | ceph_msg_data_set_bio(msg, osd_data->bio, length); |
1901 | #endif | 1922 | #endif |
1902 | } else { | 1923 | } else { |
1903 | BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); | 1924 | BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE); |