Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932580AbeAIEs1 (ORCPT + 1 other); Mon, 8 Jan 2018 23:48:27 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:45653 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932329AbeAIEsW (ORCPT ); Mon, 8 Jan 2018 23:48:22 -0500 X-Google-Smtp-Source: ACJfBoswVdeShBL7RyaiY9RLCddgTw+/Z4Nw6YPmljFWdqs6qceG0NtaejZ1YJwJKNrqicOWyNQPXQ== Date: Tue, 9 Jan 2018 13:48:17 +0900 From: Sergey Senozhatsky To: Yu Zhao Cc: Dan Streetman , Seth Jennings , Sergey Senozhatsky , Minchan Kim , Nitin Gupta , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] zswap: only save zswap header if zpool is shrinkable Message-ID: <20180109044817.GB6953@jagdpanzerIV> References: <20180108225101.15790-1-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180108225101.15790-1-yuzhao@google.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On (01/08/18 14:51), Yu Zhao wrote: [..] > int zpool_shrink(struct zpool *zpool, unsigned int pages, > unsigned int *reclaimed) > { > - return zpool->driver->shrink(zpool->pool, pages, reclaimed); > + return zpool_shrinkable(zpool) ? > + zpool->driver->shrink(zpool->pool, pages, reclaimed) : -EINVAL; > } > > /** > @@ -355,6 +356,20 @@ u64 zpool_get_total_size(struct zpool *zpool) > return zpool->driver->total_size(zpool->pool); > } > > +/** > + * zpool_shrinkable() - Test if zpool is shrinkable > + * @pool The zpool to test > + * > + * Zpool is only shrinkable when it's created with struct > + * zpool_ops.evict and its driver implements struct zpool_driver.shrink. > + * > + * Returns: true if shrinkable; false otherwise. > + */ > +bool zpool_shrinkable(struct zpool *zpool) > +{ > + return zpool->ops && zpool->ops->evict && zpool->driver->shrink; > +} just a side note, it might be a bit confusing and maybe there is a better name for it. zsmalloc is shrinkable (we register a shrinker callback), but not in the way zpool defines it. -ss