]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: s/align_down/p2align/ 29379/head
authorKefu Chai <kchai@redhat.com>
Mon, 29 Jul 2019 10:40:07 +0000 (18:40 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 29 Jul 2019 10:42:10 +0000 (18:42 +0800)
we have two implementations of align_{up,down}(). let's consolidate
them.

* s/align_up/p2roundup/
* s/align_down/p2align/
* drop common/align.h

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/align.h [deleted file]
src/os/bluestore/KernelDevice.cc
src/os/bluestore/NVMEDevice.cc

diff --git a/src/common/align.h b/src/common/align.h
deleted file mode 100644 (file)
index b5c25b9..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
-  *
- * Copyright (C) 2015 XSky <haomai@xsky.com>
- *
- * Author: Haomai Wang <haomaiwang@gmail.com>
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-#ifndef CEPH_COMMON_ALIGN_H
-#define CEPH_COMMON_ALIGN_H
-
-template <typename T>
-inline constexpr T align_up(T v, T align) {
-  return (v + align - 1) & ~(align - 1);
-}
-
-template <typename T>
-inline constexpr T align_down(T v, T align) {
-  return v & ~(align - 1);
-}
-
-#endif /* CEPH_COMMON_ALIGN_H */
index 47b321a4aac15bd85b7dce436cc8e5098c7ad282..d4f10e794166fb53315291213a9d66af7e9d3b8b 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/file.h>
 
 #include "KernelDevice.h"
+#include "include/intarith.h"
 #include "include/types.h"
 #include "include/compat.h"
 #include "include/stringify.h"
@@ -29,7 +30,6 @@
 #include "bsm/audit_errno.h"
 #endif
 #include "common/debug.h"
-#include "common/align.h"
 #include "common/numa.h"
 
 #include "global/global_context.h"
@@ -1019,8 +1019,8 @@ int KernelDevice::aio_read(
 
 int KernelDevice::direct_read_unaligned(uint64_t off, uint64_t len, char *buf)
 {
-  uint64_t aligned_off = align_down(off, block_size);
-  uint64_t aligned_len = align_up(off+len, block_size) - aligned_off;
+  uint64_t aligned_off = p2align(off, block_size);
+  uint64_t aligned_len = p2roundup(off+len, block_size) - aligned_off;
   bufferptr p = buffer::create_small_page_aligned(aligned_len);
   int r = 0;
 
index acd9eb0354659ea7bc680654165296e5f8b11b7a..107bd085bd296c291828cb7e4a7eb9102392b63d 100644 (file)
 
 #include <spdk/nvme.h>
 
+#include "include/intarith.h"
 #include "include/stringify.h"
 #include "include/types.h"
 #include "include/compat.h"
-#include "common/align.h"
 #include "common/errno.h"
 #include "common/debug.h"
 #include "common/perf_counters.h"
@@ -923,8 +923,8 @@ int NVMEDevice::read_random(uint64_t off, uint64_t len, char *buf, bool buffered
   ceph_assert(off < size);
   ceph_assert(off + len <= size);
 
-  uint64_t aligned_off = align_down(off, block_size);
-  uint64_t aligned_len = align_up(off+len, block_size) - aligned_off;
+  uint64_t aligned_off = p2align(off, block_size);
+  uint64_t aligned_len = p2roundup(off+len, block_size) - aligned_off;
   dout(5) << __func__ << " " << off << "~" << len
           << " aligned " << aligned_off << "~" << aligned_len << dendl;
   IOContext ioc(g_ceph_context, nullptr);