Skip to contentSkip to conversation

cont_prepare_write question

PATCH New Eli Carter 1 participant 1 message Jul 21, 2003 VFS

lore
Share & tools
lore

Eli Carter

author
#0 lore raw

PATCH 1/1 cont_prepare_write question

From a very basic look at cont_prepare_write() in fs/buffer.c, it looks like it needs this patch to prevent an infinite loop when extending a file by several blocks. (>8 for the 0.5k block case)

fs/buffer.c +1 -0
@@ -2118,6 +2118,7 @@
 			goto out_unmap;
 		kaddr = kmap_atomic(new_page, KM_USER0);
 		memset(kaddr+zerofrom, 0, PAGE_CACHE_SIZE-zerofrom);
+		*bytes += PAGE_CACHE_SIZE-zerofrom;
 		flush_dcache_page(new_page);
 		kunmap_atomic(kaddr, KM_USER0);
 		__block_commit_write(inode, new_page,

I'm not going to pretend that I understand why, or what this exactly accomplishes... it just seems to improve things somewhat in my case. If someone could give a basic explanation of what is going on in this loop, particularly in regards to how the loop is supposed to end, or a pointer to something to read that would make this function clearer than mud, I'd be very grateful.

Thanks,

Eli
--------------------. "If it ain't broke now,
Eli Carter \ it will be soon." -- crypto-gram
eli.carter(a)inet.com `-------------------------------------------------