Skip to contentSkip to conversation

GFS2: Fix direct IO write rounding error

PATCH New Bob Peterson 2 participants 2 messages Jan 28, 2016 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: Fix direct IO write rounding error

Hi,

The fsx test in xfstests was failing because it was using direct IO writes which were using a bad calculation. It was using loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); when it should be loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1);
Thus, the write at offset 0x67e00 was calculating lstart to be 0xe00, the address of our corruption. Instead, it should have been 0x67000. This patch fixes the calculation.

Regards,

Bob Peterson
Red Hat File Systems

---

fs/gfs2/aops.c +1 -1
index 93f0746..aa016e4 100644
@@ -1082,7 +1082,7 @@ static ssize_t gfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
 	 * the first place, mapping->nr_pages will always be zero.
 	 */
 	if (mapping->nrpages) {
-		loff_t lstart = offset & (PAGE_CACHE_SIZE - 1);
+		loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1);
 		loff_t len = iov_iter_count(iter);
 		loff_t end = PAGE_ALIGN(offset + len) - 1;
 
#2 lore raw

PATCH 1/1 GFS2: Fix direct IO write rounding error

Hi,

Quoted 10 lines · Bob Peterson

Hi,

The fsx test in xfstests was failing because it was using direct IO writes which were using a bad calculation. It was using loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); when it should be loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1);
Thus, the write at offset 0x67e00 was calculating lstart to be 0xe00, the address of our corruption. Instead, it should have been 0x67000. This patch fixes the calculation.

Quoted 6 lines

Regards,

Bob Peterson
Red Hat File Systems

Steve.

Quoted 15 lines

---

fs/gfs2/aops.c +1 -1
index 93f0746..aa016e4 100644
@@ -1082,7 +1082,7 @@ static ssize_t gfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
  	 * the first place, mapping->nr_pages will always be zero.
  	 */
  	if (mapping->nrpages) {
-		loff_t lstart = offset & (PAGE_CACHE_SIZE - 1);
+		loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1);
  		loff_t len = iov_iter_count(iter);
  		loff_t end = PAGE_ALIGN(offset + len) - 1;