Skip to contentSkip to conversation

FAT: DIO-write fallback to normal buffered

PATCH In review OGAWA Hirofumi 2 participants 2 messages Feb 10, 2007 – Feb 14, 2007 1 message not in the archive VFAT/FAT/msdos filesystem

lore
Share & tools
lore

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

OGAWA Hirofumi

author maintainer
#1 lore raw

PATCH 1/1 FAT: DIO-write fallback to normal buffered

[RESEND: forget to add [email protected]]

If the DIO write on FAT is expanding the size, it will be fail by -EINVAL, because FAT can't handle it now.

This patch fallback it to the normal buffered-write and would return success.

---

 fs/fat/inode.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/fat/inode.c renamed from fs/fat/inode.c~fat_direct-io-fallback +3 -1
diff -puN fs/fat/inode.c~fat_direct-io-fallback fs/fat/inode.c
@@ -173,10 +173,12 @@ static ssize_t fat_direct_IO(int rw, str
 		 *
 		 * But we must fill the remaining area or hole by nul for
 		 * updating ->mmu_private.
+		 *
+		 * Return 0, and fallback to normal buffered write.
 		 */
 		loff_t size = offset + iov_length(iov, nr_segs);
 		if (MSDOS_I(inode)->mmu_private < size)
-			return -EINVAL;
+			return 0;
 	}
 
 	/*

_

#2 lore raw
Quoted 9 lines · OGAWA Hirofumi

[RESEND: forget to add [email protected]]

If the DIO write on FAT is expanding the size, it will be fail by -EINVAL, because FAT can't handle it now.

This patch fallback it to the normal buffered-write and would return success.

Just to explain a bit: I think that returning EINVAL is quite unexpected
for users in this case (I actually got a bugreport which turned out to be this problem) and fallback to buffered IO seems to be a reasonable thing to do. Probably it's not the cleanest solution but for FAT I think it's good enough ;).

Honza

Quoted 23 lines

---

 fs/fat/inode.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN fs/fat/inode.c~fat_direct-io-fallback fs/fat/inode.c

fs/fat/inode.c renamed from fs/fat/inode.c~fat_direct-io-fallback +3 -1
@@ -173,10 +173,12 @@ static ssize_t fat_direct_IO(int rw, str
 		 *
 		 * But we must fill the remaining area or hole by nul for
 		 * updating ->mmu_private.
+		 *
+		 * Return 0, and fallback to normal buffered write.
 		 */
 		loff_t size = offset + iov_length(iov, nr_segs);
 		if (MSDOS_I(inode)->mmu_private < size)
-			return -EINVAL;
+			return 0;
 	}
 
 	/*

_

Signature · 2 lines
Jan Kara <[email protected]>
SuSE CR Labs