ceph: fix file offset wrapping at 4GB on 32-bit archs
authorSage Weil <sage@newdream.net>
Sat, 11 Sep 2010 17:55:25 +0000 (10:55 -0700)
committerSage Weil <sage@newdream.net>
Sat, 11 Sep 2010 17:55:25 +0000 (10:55 -0700)
Cast the value before shifting so that we don't run out of bits with a
32-bit unsigned long.  This fixes wrapping of high file offsets into the
low 4GB of a file on disk, and the subsequent data corruption for large
files.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/addr.c

index 4cfce1ee31faaf4f2f6aab966acd5d6001753940..50461b8c23a4e5db84719c67350cb7663a2fe0fc 100644 (file)
@@ -766,7 +766,8 @@ get_more_pages:
                        /* ok */
                        if (locked_pages == 0) {
                                /* prepare async write request */
-                               offset = page->index << PAGE_CACHE_SHIFT;
+                               offset = (unsigned long long)page->index
+                                       << PAGE_CACHE_SHIFT;
                                len = wsize;
                                req = ceph_osdc_new_request(&client->osdc,
                                            &ci->i_layout,