summaryrefslogtreecommitdiffstats
path: root/fs/ceph/file.c
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-08-27 12:15:16 -0700
committerSage Weil <sage@inktank.com>2013-08-27 12:26:29 -0700
commitb314a90d8f3f1d16ec45744e5e2141ea6e14e034 (patch)
treeda7c19d362ab97d8de74614fb1a72575640ed445 /fs/ceph/file.c
parentad7a60de882aca31afb58721db166f7e77afcd92 (diff)
downloadop-kernel-dev-b314a90d8f3f1d16ec45744e5e2141ea6e14e034.zip
op-kernel-dev-b314a90d8f3f1d16ec45744e5e2141ea6e14e034.tar.gz
ceph: fix fallocate division
We need to use do_div to divide by a 64-bit value. Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'fs/ceph/file.c')
-rw-r--r--fs/ceph/file.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 68af489..d5e12f5 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -960,13 +960,17 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)
{
int ret = 0;
struct ceph_inode_info *ci = ceph_inode(inode);
- __s32 stripe_unit = ceph_file_layout_su(ci->i_layout);
- __s32 stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
- __s32 object_size = ceph_file_layout_object_size(ci->i_layout);
- loff_t object_set_size = (loff_t)object_size * stripe_count;
+ s32 stripe_unit = ceph_file_layout_su(ci->i_layout);
+ s32 stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
+ s32 object_size = ceph_file_layout_object_size(ci->i_layout);
+ u64 object_set_size = object_size * stripe_count;
+ u64 nearly, t;
+
+ /* round offset up to next period boundary */
+ nearly = offset + object_set_size - 1;
+ t = nearly;
+ nearly -= do_div(t, object_set_size);
- loff_t nearly = (offset + object_set_size - 1)
- / object_set_size * object_set_size;
while (length && offset < nearly) {
loff_t size = length;
ret = ceph_zero_partial_object(inode, offset, &size);
OpenPOWER on IntegriCloud