+++ /dev/null
-// -*- 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 */
#include <sys/file.h>
#include "KernelDevice.h"
+#include "include/intarith.h"
#include "include/types.h"
#include "include/compat.h"
#include "include/stringify.h"
#include "bsm/audit_errno.h"
#endif
#include "common/debug.h"
-#include "common/align.h"
#include "common/numa.h"
#include "global/global_context.h"
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;
#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"
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);