diff options
Diffstat (limited to 'net/ceph/osdmap.c')
-rw-r--r-- | net/ceph/osdmap.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 3124b71a8883..5433fb0eb3c6 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -984,7 +984,7 @@ bad: | |||
984 | * for now, we write only a single su, until we can | 984 | * for now, we write only a single su, until we can |
985 | * pass a stride back to the caller. | 985 | * pass a stride back to the caller. |
986 | */ | 986 | */ |
987 | void ceph_calc_file_object_mapping(struct ceph_file_layout *layout, | 987 | int ceph_calc_file_object_mapping(struct ceph_file_layout *layout, |
988 | u64 off, u64 *plen, | 988 | u64 off, u64 *plen, |
989 | u64 *ono, | 989 | u64 *ono, |
990 | u64 *oxoff, u64 *oxlen) | 990 | u64 *oxoff, u64 *oxlen) |
@@ -998,11 +998,17 @@ void ceph_calc_file_object_mapping(struct ceph_file_layout *layout, | |||
998 | 998 | ||
999 | dout("mapping %llu~%llu osize %u fl_su %u\n", off, *plen, | 999 | dout("mapping %llu~%llu osize %u fl_su %u\n", off, *plen, |
1000 | osize, su); | 1000 | osize, su); |
1001 | if (su == 0 || sc == 0) | ||
1002 | goto invalid; | ||
1001 | su_per_object = osize / su; | 1003 | su_per_object = osize / su; |
1004 | if (su_per_object == 0) | ||
1005 | goto invalid; | ||
1002 | dout("osize %u / su %u = su_per_object %u\n", osize, su, | 1006 | dout("osize %u / su %u = su_per_object %u\n", osize, su, |
1003 | su_per_object); | 1007 | su_per_object); |
1004 | 1008 | ||
1005 | BUG_ON((su & ~PAGE_MASK) != 0); | 1009 | if ((su & ~PAGE_MASK) != 0) |
1010 | goto invalid; | ||
1011 | |||
1006 | /* bl = *off / su; */ | 1012 | /* bl = *off / su; */ |
1007 | t = off; | 1013 | t = off; |
1008 | do_div(t, su); | 1014 | do_div(t, su); |
@@ -1030,6 +1036,14 @@ void ceph_calc_file_object_mapping(struct ceph_file_layout *layout, | |||
1030 | *plen = *oxlen; | 1036 | *plen = *oxlen; |
1031 | 1037 | ||
1032 | dout(" obj extent %llu~%llu\n", *oxoff, *oxlen); | 1038 | dout(" obj extent %llu~%llu\n", *oxoff, *oxlen); |
1039 | return 0; | ||
1040 | |||
1041 | invalid: | ||
1042 | dout(" invalid layout\n"); | ||
1043 | *ono = 0; | ||
1044 | *oxoff = 0; | ||
1045 | *oxlen = 0; | ||
1046 | return -EINVAL; | ||
1033 | } | 1047 | } |
1034 | EXPORT_SYMBOL(ceph_calc_file_object_mapping); | 1048 | EXPORT_SYMBOL(ceph_calc_file_object_mapping); |
1035 | 1049 | ||