Re: [PATCH v3] zram: support REQ_DISCARD
From: Joonsoo Kim
Date: Thu Mar 13 2014 - 00:23:27 EST
On Wed, Mar 12, 2014 at 08:03:03PM -0700, Andrew Morton wrote:
> On Thu, 13 Mar 2014 11:46:17 +0900 Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> wrote:
>
> > + while (n >= PAGE_SIZE) {
> > + /*
> > + * discard request can be too large so that the zram can
> > + * be stucked for a long time if we handle the request
> > + * at once. So handle the request by PAGE_SIZE unit at a time.
> > + */
> > + write_lock(&zram->meta->tb_lock);
> > + zram_free_page(zram, index);
> > + write_unlock(&zram->meta->tb_lock);
> > + index++;
> > + n -= PAGE_SIZE;
> > + }
>
> Well, you could use something like
>
> if (need_resched()) {
> unlock()
> schedule()
> lock()
> }
>
> here, or free 100 pages at a time or something silly like that. I
> guess we retain these as options if/when that lock turns out to be
> contended.
Okay! I postpone this until that lock turns out to be contented.
Here goes new one.
Thanks.
-------------->8-----------------------