A question on block_prepare_write()
Hello,
I see block_prepare_write() has local variable wait[2] to keep track of buffer_heads which are not up-to-date. But I'm wondering how it could be guaranteed there will be no more than 2 such buffer_heads? Is there any restriction on the usage of the function? Using MAX_BUF_PER_PAGE instead of the magic number 2 is just useless? I couldn't find any comments or documentation on this.
Any of your comments would be greatly appreciated. TIA. :-)
Signature · 2 lines
Regards, Namhyung Kim
Quoted 11 lines · On Sat, 23 Oct 2010 22:44:42 +0900 Namhyung Kim <[email protected]> wrote:
Hello,
I see
block_prepare_write()has local variable wait[2] to keep track ofbuffer_headswhich are not up-to-date. But I'm wondering how it could be guaranteed there will be no more than 2 suchbuffer_heads? Is there any restriction on the usage of the function? UsingMAX_BUF_PER_PAGEinstead of the magic number 2 is just useless? I couldn't find any comments or documentation on this.Any of your comments would be greatly appreciated. TIA. :-)
block_prepare_write() may need to preread any buffer_head which are being only partially modified by the write().
Buffers which aren't being modified at all don't need to be preread. Buffers which are being fully modified don't need to be preread (because all their data is being overwritten).
page: |-----------------------| buffer_heads: |-----|-----|-----|-----|
area we're writing to: |---------|
There can only be a maximum of two partially-modified buffers in the page.
2010-10-23 (토), 10:40 -0700, Andrew Morton:
Quoted 21 lines · On Sat, 23 Oct 2010 22:44:42 +0900 Namhyung Kim <[email protected]> wrote:
Quoted 12 lines
Hello,
I see
block_prepare_write()has local variable wait[2] to keep track ofbuffer_headswhich are not up-to-date. But I'm wondering how it could be guaranteed there will be no more than 2 suchbuffer_heads? Is there any restriction on the usage of the function? UsingMAX_BUF_PER_PAGEinstead of the magic number 2 is just useless? I couldn't find any comments or documentation on this.Any of your comments would be greatly appreciated. TIA. :-)
block_prepare_write()may need to preread anybuffer_headwhich are being only partially modified by thewrite().Buffers which aren't being modified at all don't need to be preread. Buffers which are being fully modified don't need to be preread (because all their data is being overwritten).
Quoted 5 lines
page: |-----------------------| buffer_heads: |-----|-----|-----|-----|area we're writing to: |---------|
There can only be a maximum of two partially-modified buffers in the page.
I see. It considers both edges of the to-be-written data. Thanks for your clear and kindly explanation. :-)
Signature · 8 lines
Regards, Namhyung Kim -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html