lkml.org 
[lkml]   [2011]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Xen-devel] [PATCH 3/3] xen/blk[front|back]: Enhance discard support with secure erasing support.
> >             if (operation != REQ_DISCARD)
> > /* Check that the number of segments is sane. */
> > nseg = req->nr_segments;
> > else
> > nseg = 0;
>
> Right above this hunk is a switch statement over the req->operation. The
> value of req->operation precisely defines the semantics/validity or
> otherwise of the req->nr_segments field and whether or not it contains
> the nr of segments or (due to the aliasing) something else. Why not set
> nsegs inside that switch statement (and explicitly zero it in the other
> cases) so that this obvious connection is retained?

Sure.
>
> > > > if (unlikely(nseg == 0 && operation != WRITE_FLUSH &&
> > > > operation != REQ_DISCARD) ||
> >
> > And I guess we can also skip the REQ_DISCARD test here.
>
> I don't think so, if nseg == 0 and operation == REQ_DISCARD that is
> fine, right? The fact that there is all this "operation != xx &&

<nods>

..snip..
> (I think I'm right that BLKIF_OP_FLUSH_DISKCACHE can have associated
> data or not)

You are right.
>
> However do discard and r/w really have so much in common that handling
> them all in dispatch_rw_block_io() and relying on nsegs == 0 when the
> operation is discard makes sense?
>
> Would it be clearer if the caller (__do_block_io_op) had this switch
> over req->operation and called dispatch_rw_block_io(req, WRITE_FLUSH,
> nsegs), dispatch_discard(req) etc as appropriate?

Potentially. It would cut down on this functions bloated size so that
is a definite plus.


\
 
 \ /
  Last update: 2011-10-12 19:33    [W:0.044 / U:33.444 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site