linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: linux-lvm@redhat.com
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Subject: [linux-lvm] [PATCH] lib/device/bcache: don't use PAGE_SIZE
Date: Wed, 16 May 2018 21:19:03 +0100	[thread overview]
Message-ID: <20180516201903.24309-1-alex.bennee@linaro.org> (raw)

PAGE_SIZE is not a compile time constant. Use sysconf instead like
elsewhere in the code.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 lib/device/bcache.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 30df54a90..53a62aaee 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -162,8 +162,9 @@ static bool _async_issue(struct io_engine *ioe, enum dir d, int fd,
 	struct iocb *cb_array[1];
 	struct control_block *cb;
 	struct async_engine *e = _to_async(ioe);
+        long pgsize = sysconf(_SC_PAGESIZE);
 
-	if (((uintptr_t) data) & (PAGE_SIZE - 1)) {
+	if (((uintptr_t) data) & (pgsize - 1)) {
 		log_warn("misaligned data buffer");
 		return false;
 	}
@@ -547,8 +548,9 @@ static bool _init_free_list(struct bcache *cache, unsigned count)
 {
 	unsigned i;
 	size_t block_size = cache->block_sectors << SECTOR_SHIFT;
+        long pgsize = sysconf(_SC_PAGESIZE);
 	unsigned char *data =
-		(unsigned char *) _alloc_aligned(count * block_size, PAGE_SIZE);
+		(unsigned char *) _alloc_aligned(count * block_size, pgsize);
 
 	/* Allocate the data for each block.  We page align the data. */
 	if (!data)
@@ -899,6 +901,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks,
 {
 	struct bcache *cache;
 	unsigned max_io = engine->max_io(engine);
+        long pgsize = sysconf(_SC_PAGESIZE);
 
 	if (!nr_cache_blocks) {
 		log_warn("bcache must have at least one cache block");
@@ -910,7 +913,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks,
 		return NULL;
 	}
 
-	if (block_sectors & ((PAGE_SIZE >> SECTOR_SHIFT) - 1)) {
+	if (block_sectors & ((pgsize >> SECTOR_SHIFT) - 1)) {
 		log_warn("bcache block size must be a multiple of page size");
 		return NULL;
 	}
-- 
2.17.0

             reply	other threads:[~2018-05-16 20:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 20:19 Alex Bennée [this message]
2018-05-17  9:07 ` [linux-lvm] [PATCH] lib/device/bcache: don't use PAGE_SIZE Joe Thornber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180516201903.24309-1-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=linux-lvm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).