linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nitin Gupta <ngupta@vflare.org>
To: Jens Axboe <jaxboe@fusionio.com>
Cc: Pekka Enberg <penberg@kernel.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Minchan Kim <minchan.kim@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg KH <greg@kroah.com>,
	Linux Driver Project <devel@linuxdriverproject.org>,
	linux-mm <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 06/10] Block discard support
Date: Tue, 10 Aug 2010 10:24:57 +0530	[thread overview]
Message-ID: <4C60DBA1.5070507@vflare.org> (raw)
In-Reply-To: <4C60B82B.5020905@fusionio.com>

On 08/10/2010 07:53 AM, Jens Axboe wrote:
> On 08/09/2010 03:03 PM, Pekka Enberg wrote:
>> On Mon, Aug 9, 2010 at 8:26 PM, Nitin Gupta <ngupta@vflare.org> wrote:
>>> The 'discard' bio discard request provides information to
>>> zram disks regarding blocks which are no longer in use by
>>> filesystem. This allows freeing memory allocated for such
>>> blocks.
>>>
>>> When zram devices are used as swap disks, we already have
>>> a callback (block_device_operations->swap_slot_free_notify).
>>> So, the discard support is useful only when used as generic
>>> (non-swap) disk.
>>>
>>> Signed-off-by: Nitin Gupta <ngupta@vflare.org>
>>
>> Lets CC fsdevel and Jens for this.
> 
> Looks OK from a quick look. One comment, though:
> 
>>> +static void zram_discard(struct zram *zram, struct bio *bio)
>>> +{
>>> +       size_t bytes = bio->bi_size;
>>> +       sector_t sector = bio->bi_sector;
>>> +
>>> +       while (bytes >= PAGE_SIZE) {
>>> +               zram_free_page(zram, sector >> SECTORS_PER_PAGE_SHIFT);
>>> +               sector += PAGE_SIZE >> SECTOR_SHIFT;
>>> +               bytes -= PAGE_SIZE;
>>> +       }
>>> +
>>> +       bio_endio(bio, 0);
>>> +}
>>> +
> 
> So freeing the page here will guarantee zeroed return on read?

For reads on freed/unwritten sectors, it simply returns success and
does not touch the bio page. Is it better to zero the page in such
cases?

> And since you set PAGE_SIZE as the discard granularity, the above loop
> could be coded more readable with the knowledge that ->bi_size is always
> a multiple of the page size.
> 

Ok, I will cleanup it up.

Thanks for comments.
Nitin

  reply	other threads:[~2010-08-10  4:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1281374816-904-1-git-send-email-ngupta@vflare.org>
     [not found] ` <1281374816-904-7-git-send-email-ngupta@vflare.org>
2010-08-09 19:03   ` [PATCH 06/10] Block discard support Pekka Enberg
2010-08-10  2:23     ` Jens Axboe
2010-08-10  4:54       ` Nitin Gupta [this message]
2010-08-10 15:54         ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C60DBA1.5070507@vflare.org \
    --to=ngupta@vflare.org \
    --cc=akpm@linux-foundation.org \
    --cc=devel@linuxdriverproject.org \
    --cc=greg@kroah.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=penberg@cs.helsinki.fi \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).