Hi,<br><br>On Mon, Jul 30, 2012 at 6:14 PM, Dave Chinner &lt;<a href="mailto:david@fromorbit.com">david@fromorbit.com</a>&gt; wrote:<br>&gt; On Tue, Jul 31, 2012 at 08:55:59AM +0800, majianpeng wrote:<br>&gt;&gt; On 2012-07-31 05:42 Dave Chinner &lt;<a href="mailto:david@fromorbit.com">david@fromorbit.com</a>&gt; Wrote:<br>
&gt;&gt; &gt;On Mon, Jul 30, 2012 at 03:14:28PM +0800, majianpeng wrote:<br>&gt;&gt; &gt;&gt; When exec bio_alloc, the bi_rw is zero.But after calling bio_add_page,<br>&gt;&gt; &gt;&gt; it will use bi_rw.<br>&gt;&gt; &gt;&gt; Fox example, in functiion __bio_add_page,it will call merge_bvec_fn().<br>
&gt;&gt; &gt;&gt; The merge_bvec_fn of raid456 will use the bi_rw to judge the merge.<br>&gt;&gt; &gt;&gt; &gt;&gt; if ((bvm-&gt;bi_rw &amp; 1) == WRITE)<br>&gt;&gt; &gt;&gt; &gt;&gt; return biovec-&gt;bv_len; /* always allow writes to be mergeable */<br>
&gt;&gt; &gt;<br>&gt;&gt; &gt;So if bio_add_page() requires bi_rw to be set, then shouldn&#39;t it be<br>&gt;&gt; &gt;set up for every caller? I noticed there are about 50 call sites for<br>&gt;&gt; &gt;bio_add_page(), and you&#39;ve only touched about 10 of them. Indeed, I<br>
&gt;&gt; &gt;notice that the RAID0/1 code uses bio_add_page, and as that can be<br>&gt;&gt; &gt;stacked on top of RAID456, it also needs to set bi_rw correctly.<br>&gt;&gt; &gt;As a result, your patch set is nowhere near complete, not does it<br>
&gt;&gt; &gt;document that bio_add_page requires that bi_rw be set before calling<br>&gt;&gt; &gt;(which is the new API requirement, AFAICT).<br>&gt;&gt; There are many place call bio_add_page and I send some of those. Because my abilty, so I only send<br>
&gt;&gt; some patchs which i understand clearly.<br>&gt;<br>&gt; Sure, but my point is that there is no point changing only a few and<br>&gt; ignoring the great majority of callers. Either fix them all, fix it<br>&gt; some other way (e.g. API change), or remove the code from the RAID5<br>
&gt; function that requires it.<br>&gt;<br><br><br>A while back, we tried to address this by changing the alloc functions to take rw argument and set it (as per Jens suggestion). I guess the patch did not make it in. Please check:<br>
<br><a href="https://lkml.org/lkml/2011/7/11/275">https://lkml.org/lkml/2011/7/11/275</a><br><br>And the follow ups. If needed, I can dust up that patch and resend it.<br><br><br>&gt;&gt; In __bio_add_page:<br>&gt;&gt; &gt;&gt;if (q-&gt;merge_bvec_fn) {<br>
&gt;&gt; &gt;&gt;                            struct bvec_merge_data bvm = {<br>&gt;&gt; &gt;&gt;                                    /* prev_bvec is already charged in<br>&gt;&gt; &gt;&gt;                                       bi_size, discharge it in order to<br>
&gt;&gt; &gt;&gt;                                       simulate merging updated prev_bvec<br>&gt;&gt; &gt;&gt;                                       as new bvec. */<br>&gt;&gt; &gt;&gt;                                    .bi_bdev = bio-&gt;bi_bdev,<br>
&gt;&gt; &gt;&gt;                                    .bi_sector = bio-&gt;bi_sector,<br>&gt;&gt; &gt;&gt;                                    .bi_size = bio-&gt;bi_size - prev_bv_len,<br>&gt;&gt; &gt;&gt;                                    .bi_rw = bio-&gt;bi_rw,<br>
&gt;&gt; &gt;&gt;                            };<br>&gt;&gt; it used bio-&gt;bi_rw.<br>&gt;&gt; Before raid5_mergeable_bvec appearing, in kernel &#39;merge_bvec_fn&#39; did not use bio-&gt;bi_rw.<br>&gt;<br><br>&lt;snip&gt;<br>
<br><br>&gt; It&#39;s entirely possible that when bi_rw was added to struct<br>&gt; bvec_merge_data, the person who added it was mistaken that bi_rw was<br>&gt; set at this point in time when in fact it never has been. Hence it&#39;s<br>
&gt; presence and reliance on it would be a bug.<br>&gt;<br>&gt; That&#39;s what I&#39;m asking - is this actually beneificial, or should it<br>&gt; simply be removed from struct bvec_merge_data? Data is needed to<br>&gt; answer that question....<br>
<br><br>There are cases where we found it really beneficial to know the rw field to decide if the can be really merged or not.<br><br>Regards,<br>Muthu<br><br><br>&gt;<br>&gt; Cheers,<br>&gt;<br>&gt; Dave.<br>&gt; --<br>&gt; Dave Chinner<br>
&gt; <a href="mailto:david@fromorbit.com">david@fromorbit.com</a><br>&gt; --<br>&gt; To unsubscribe from this list: send the line &quot;unsubscribe linux-kernel&quot; in<br>&gt; the body of a message to <a href="mailto:majordomo@vger.kernel.org">majordomo@vger.kernel.org</a><br>
&gt; More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br>&gt; Please read the FAQ at  <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br>
<br>