[1/3] iomap: use SECTOR_SIZE instead of 512 in iomap_page
diff mbox series

Message ID 1544739929-21651-2-git-send-email-sandeen@sandeen.net
State New
Headers show
Series
  • iomap: 1 cleanup, 1 fix, 1 optimization
Related show

Commit Message

Eric Sandeen Dec. 13, 2018, 10:25 p.m. UTC
From: Eric Sandeen <sandeen@redhat.com>

because iomap_page_create initializes the uptodate bitmap using the macro,
not the open-coded value.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
 include/linux/iomap.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Dec. 15, 2018, 10:51 a.m. UTC | #1
On Thu, Dec 13, 2018 at 04:25:27PM -0600, Eric Sandeen wrote:
> From: Eric Sandeen <sandeen@redhat.com>
> 
> because iomap_page_create initializes the uptodate bitmap using the macro,
> not the open-coded value.

I find the use of SECTOR_SIZE rather confusing, especially as often
the sector size might actually be something else.  It also forces
us to pull in another huge header file.
Eric Sandeen Dec. 17, 2018, 11:45 p.m. UTC | #2
On 12/15/18 4:51 AM, Christoph Hellwig wrote:
> On Thu, Dec 13, 2018 at 04:25:27PM -0600, Eric Sandeen wrote:
>> From: Eric Sandeen <sandeen@redhat.com>
>>
>> because iomap_page_create initializes the uptodate bitmap using the macro,
>> not the open-coded value.
> 
> I find the use of SECTOR_SIZE rather confusing, especially as often
> the sector size might actually be something else.  It also forces
> us to pull in another huge header file.

Then we should hard code "512" in iomap_page_create I guess.  Just need
consistency.

-Eric
Christoph Hellwig Dec. 18, 2018, 6:06 p.m. UTC | #3
On Mon, Dec 17, 2018 at 05:45:10PM -0600, Eric Sandeen wrote:
> Then we should hard code "512" in iomap_page_create I guess.  Just need
> consistency.

Fine with me.
Darrick J. Wong Dec. 18, 2018, 6:19 p.m. UTC | #4
On Tue, Dec 18, 2018 at 07:06:17PM +0100, Christoph Hellwig wrote:
> On Mon, Dec 17, 2018 at 05:45:10PM -0600, Eric Sandeen wrote:
> > Then we should hard code "512" in iomap_page_create I guess.  Just need
> > consistency.
> 
> Fine with me.

Please don't just hardcode 512 here.  AFAICT the usage in iomap.c seems
to be "minimum expected fs block size" so that the iop's uptodate bitmap
is sized to handle the worst case blocks-per-page.

Can we please have a "#define IOMAP_MIN_FS_BLOCKSIZE SECTOR_SIZE" to
capture the intent behind the 512?  Or, if you don't want to require all
includers of iomap.h to also have to include blkdev.h, define it to 512
and have a BUILD_BUG_ON somewhere so that we don't leave a subtle bug if
we ever change SECTOR_SIZE?

--D
Eric Sandeen Dec. 18, 2018, 6:20 p.m. UTC | #5
On 12/18/18 12:19 PM, Darrick J. Wong wrote:
> On Tue, Dec 18, 2018 at 07:06:17PM +0100, Christoph Hellwig wrote:
>> On Mon, Dec 17, 2018 at 05:45:10PM -0600, Eric Sandeen wrote:
>>> Then we should hard code "512" in iomap_page_create I guess.  Just need
>>> consistency.
>>
>> Fine with me.
> 
> Please don't just hardcode 512 here.  AFAICT the usage in iomap.c seems
> to be "minimum expected fs block size" so that the iop's uptodate bitmap
> is sized to handle the worst case blocks-per-page.
> 
> Can we please have a "#define IOMAP_MIN_FS_BLOCKSIZE SECTOR_SIZE" to
> capture the intent behind the 512?  Or, if you don't want to require all
> includers of iomap.h to also have to include blkdev.h, define it to 512
> and have a BUILD_BUG_ON somewhere so that we don't leave a subtle bug if
> we ever change SECTOR_SIZE?

Right, seems like something needs to tie this into the rest of reality
and not just blaze past it if we somehow ever encounter a block size
< 512.

-Eric

Patch
diff mbox series

diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 9a42581..edcdb3a 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -4,6 +4,7 @@ 
 
 #include <linux/atomic.h>
 #include <linux/bitmap.h>
+#include <linux/blkdev.h>
 #include <linux/mm.h>
 #include <linux/types.h>
 #include <linux/mm_types.h>
@@ -104,12 +105,13 @@  struct iomap_ops {
 
 /*
  * Structure allocate for each page when block size < PAGE_SIZE to track
- * sub-page uptodate status and I/O completions.
+ * sub-page uptodate status and I/O completions.  Allocate bitmap to
+ * accomodate blocks as small as SECTOR_SIZE
  */
 struct iomap_page {
 	atomic_t		read_count;
 	atomic_t		write_count;
-	DECLARE_BITMAP(uptodate, PAGE_SIZE / 512);
+	DECLARE_BITMAP(uptodate, PAGE_SIZE / SECTOR_SIZE);
 };
 
 static inline struct iomap_page *to_iomap_page(struct page *page)