On Thu, 19 Nov 2009, FUJITA Tomonori wrote: ... > As you suggested earlier, looks like normalize_buffer() doesn't free > all the buffers. I think that I found one bug that causes to this. > > When enlarge_buffer() allocates 524288 from 0, st uses six-order page > allocation. So mdata->page_order is 6 and frp_seg is 2. > > After that, if st uses dio, sgl_map_user_pages() sets > mdata->page_order to 0 for st_do_scsi(). After that, when we call > normalize_buffer(), it frees only free frp_seg * PAGE_SIZE (2 * 4096) > though we should free frp_seg * PAGE_SIZE << 6 (2 * 4096 << 6). So we > see buffer_size is set to 516096 (524288 - 8192). > This surely can cause problems later. > Here's a fix for this. > I have tested the patch. Amanda did make the backup without problems. However, looking at dmesg revealed that this time it did not use dio with any write. Then I made a small program that writes both with and without dio (when the write buffer is not aligned at page boundary, it needs 129 s/g segments and dio is not used). Dmesg showed that dio was used in half of the writes and the buffer was shrunk properly. Thanks, Kai -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html