Whamcloud - gitweb
LU-12025 osp: allow OS_STATE_* flags from OSTs
[fs/lustre-release.git] / lustre / utils / liblustreapi_mirror.c
index 464b9fb..bae3b09 100644 (file)
@@ -147,8 +147,8 @@ ssize_t llapi_mirror_read(int fd, unsigned int id, void *buf, size_t count,
        return result;
 }
 
-static ssize_t llapi_mirror_write(int fd, unsigned int id,
-                                  const void *buf, size_t count, off_t pos)
+ssize_t llapi_mirror_write(int fd, unsigned int id, const void *buf,
+                          size_t count, off_t pos)
 {
        size_t page_size = sysconf(_SC_PAGESIZE);
        ssize_t result = 0;
@@ -186,7 +186,7 @@ static ssize_t llapi_mirror_write(int fd, unsigned int id,
        return result;
 }
 
-static int llapi_mirror_truncate(int fd, unsigned int id, off_t length)
+int llapi_mirror_truncate(int fd, unsigned int id, off_t length)
 {
        int rc;
 
@@ -216,8 +216,7 @@ static int llapi_mirror_truncate(int fd, unsigned int id, off_t length)
  * \result > 0 Number of mirrors successfully copied
  * \result < 0 The last seen error
  */
-ssize_t llapi_mirror_copy_many(int fd, unsigned int src, unsigned int *dst,
-                               size_t count)
+ssize_t llapi_mirror_copy_many(int fd, __u16 src, __u16 *dst, size_t count)
 {
        const size_t buflen = 4 * 1024 * 1024; /* 4M */
        void *buf;
@@ -252,7 +251,7 @@ ssize_t llapi_mirror_copy_many(int fd, unsigned int src, unsigned int *dst,
 
                /* round up to page align to make direct IO happy.
                 * this implies the last segment to write. */
-               to_write = (bytes_read + page_size - 1) & ~(page_size - 1);
+               to_write = ((bytes_read - 1) | (page_size - 1)) + 1;
 
                for (i = 0; i < nr; i++) {
                        ssize_t written;