From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753605AbbD2HCG (ORCPT ); Wed, 29 Apr 2015 03:02:06 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33081 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbbD2HCC (ORCPT ); Wed, 29 Apr 2015 03:02:02 -0400 Date: Wed, 29 Apr 2015 16:02:18 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [PATCHv3 9/9] zram: add dynamic device add/remove functionality Message-ID: <20150429070218.GA616@swordfish> References: <1430140911-7818-1-git-send-email-sergey.senozhatsky@gmail.com> <1430140911-7818-10-git-send-email-sergey.senozhatsky@gmail.com> <20150429001624.GA3917@swordfish> <20150429064858.GA5125@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150429064858.GA5125@blaptop> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Minchan, On (04/29/15 15:48), Minchan Kim wrote: [..] > > > > CPU0 CPU1 > > umount > > zram_remove() > > zram_reset_device() disksize_store() > > mount > > kfree zram > > > > or > > > > CPU0 CPU1 > > umount > > zram_remove() > > zram_reset_device() > > cat /sys/block/zram0/_any_sysfs_node_ > > sysfs_remove_group() > > kfree zram _any_sysfs_node_read() > > > > > > and so on. so removing sysfs group before zram_reset_device() makes sense. > > > > at the same time we need to prevent `umount-zram_remove vs. mount' race and forbid > > zram_remove() on active device. so we check ->bd_openers and perform device reset > > under ->bd_mutex. > > > > Could you explain in detail about unmount-zram_remove vs. mount race? > I guess it should be done in upper layer(e,g. VFS). Anyway, I want to be > more clear about that. > sure. I was talking about this one: CPU0 CPU1 umount zram_remove() lock ->bd_mutex zram_reset_device() unlock ->bd_mutex disksize_store mount echo 'test' > /mnt/test kfree zram zram write w/o ->bd_mutex around zram_reset_device() it's evern simpler, I guess. hm, I don't think VFS can help us here. -ss