Re: [Fwd: [PATCH] consolidate generic_writepages and mpage_writepages]

From: Miklos Szeredi
Date: Sat Feb 17 2007 - 05:16:17 EST


> >Maybe cifs_writepages() too can use this infrastructure, but I'm not
> >touching that with a ten-foot pole.
> >
> >
> The cifs case ought to be one of the simpler ones, pseudo-code is pretty
> easy, the hard part is all of the stuff unrelated to cifs:
> Ideally if there were generic functions to help out, cifs writepages
> would look roughly like the following
>
> cifs_writepages(struct address_space *mapping, struct writeback_control
> *wbc)
> {
>
> while (no more pages to write) {
> /* find writeable file handle for this inode */
> /* find the biggest set of contiguous pages that total less than
> wsize */
> if (packet signing is enabled)
> /* write lock pages so they can not be changed under us
> while we are calculating the checksum */
>
> CIFSSMBWrite2(tree_connection, network_file_handle, array of
> iovecs, number of iovecs);
>
> if(packet signing was enabled)
> /* unlock pages */
>
> if(error) {
> set page errors
> if (mounted "hard" )
> continue; /* retry */
> else /* if no retry possible */
> return error to caller;
> }
> update bytes written statistics
> update index to point to next set of pages
> } /* end while loop */
> }

write_cache_pages() now takes care of the

while (no more pages to write) {
}

part. All you have to do is to make the body of the loop into a
function and pass it a structure with the data you want to preserve
between invocations.

The hard part is untangling the breaks and continues.

Miklos
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/