From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: Re: [RFC] Draft Linux kernel interfaces for ZBC drives Date: Fri, 31 Jan 2014 06:07:54 -0700 Message-ID: <20140131130754.GI20939@parisc-linux.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org To: Theodore Ts'o Return-path: Received: from palinux.external.hp.com ([192.25.206.14]:37508 "EHLO mail.parisc-linux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932146AbaAaNH4 (ORCPT ); Fri, 31 Jan 2014 08:07:56 -0500 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Jan 31, 2014 at 12:38:22AM -0500, Theodore Ts'o wrote: > /* > * Note: this structure is 24 bytes. Using 256 MB zones, an 8TB drive > * will have 32,768 zones. That means if we tried to use a contiguous > * array we would need to allocate 768k of contiguous, non-swappable > * kernel memory. (Boo, hiss.) > * > * This large enough that it would be painful to hang an array off the > * block_device structure. So we will define a function > * blkdev_query_zones() to selectively return information for some > * number of zones. > */ > struct zone_status { > sector_t z_start; > __u32 z_length; > __u32 z_write_ptr_offset; /* offset */ > __u32 z_checkpoint_offset; /* offset */ > __u32 z_flags; /* full, ro, offline, reset_requested */ > }; > > /* > * Query the block_device bdev for information about the zones > * starting at start_sector that match the criteria specified by > * free_sectors_criteria. Zone status information for at most > * max_zones will be placed into the memory array ret_zones. The > * return value contains the number of zones actually returned. > * > * If free_sectors_criteria is positive, then return zones that have > * at least that many sectors available to be written. If it is zero, > * then match all zones. If free_sectors_criteria is negative, then > * return the zones that match the following criteria: > * > * -1 Return all read-only zones > * -2 Return all offline zones > * -3 Return all zones where the write ptr != the checkpoint ptr > */ > extern int blkdev_query_zones(struct block_device *bdev, > sector_t start_sector, > int free_sectors_criteria, > struct zone_status *ret_zones, > int max_zones); So the caller does: zones = kmalloc(max * sizeof *zones, GFP_KERNEL); blkdev_query_zones(bdev, sector, fsc, zones, max); ... kfree(zones); Just want to be sure I understand the lifetime rules on the memory used. I imagine the block layer will have some kind of compressed representation, probably a tree of some kind, then expand that representation into the zone_status. -- Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."