On Tue, 2017-11-21 at 11:04 +0800, piaojun wrote:
> > >   new = NULL;
> > >  unlock:
> > >   spin_unlock(&oi->ip_lock);
> > > @@ -2246,7 +2250,7 @@ static int ocfs2_dio_get_block(struct inode
> > > *inode, sector_t iblock,
> > >           ue->ue_phys = desc->c_phys;
> > >  
> > >           list_splice_tail_init(&wc->w_unwritten_list,
> > > &dwc->dw_zero_list);
> > > -         dwc->dw_zero_count++;
> > > +         dwc->dw_zero_count += wc->w_unwritten_count;
> 
> I prefer using a loop to calculate 'dwc->dw_zero_count' rather than
> introducing a new variable as below:
> 
> list_for_each(iter, &wc->w_unwritten_list)
>       dwc->dw_zero_count++;

If you want to iterate through the list to calculate the length rather
than tracking the length as the list grows, it would make more sense to
remove dw_zero_count.

If you'd prefer walking all of the elements to calculate the length,
this can just be done in ocfs2_dio_end_io_write() where the length of
the list is actually used.

I assumed that the intent of dw_zero_count was to avoid an unnecessary
iteration through dw_zero_list to determine the length.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

Reply via email to