From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbbL1U66 (ORCPT ); Mon, 28 Dec 2015 15:58:58 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:48993 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbbL1U6z (ORCPT ); Mon, 28 Dec 2015 15:58:55 -0500 X-Sasl-enc: NuJtIxiJvqWlI13Qr8aMesMxwOkKmkDEAX/EwDtZbifV 1451336334 Date: Mon, 28 Dec 2015 12:58:33 -0800 From: Greg Kroah-Hartman To: Rajat Jain Cc: "linux-kernel@vger.kernel.org" , linux-newbie@vger.kernel.org Subject: Re: debugfs_remove_recursive() while a file is in use by userspace Message-ID: <20151228205833.GA20955@kroah.com> References: <20151228203121.GA19753@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 28, 2015 at 12:51:32PM -0800, Rajat Jain wrote: > Thanks Greg and Al for the quick turnaround. > > Essentially I have a device that supports something called "contexts" > that can be "created" and "destroyed" during the life of the device. I > want to expose some debug files for the context when it is created, > and destroy the files when the context is destroyed. However, I'm not > sure how do I ensure that the user is not in the middle of reading / > writing / mmaping to those files. Also how do I know that user is > still not holding a reference to the file structure. You don't. > It seems like debugfs is currently not a good choice for this? Would > you recommend me to any other fs or subsystem that I should use for > this? What exactly do you need to export to userspace and for what purpose? For debugging-only stuff, sure, use debugfs, but don't rely on it for any "real" tools, only your own debugging. > Would hanging those files under the sysfs node for the device sound > any better (by representing each "context" using an embedded kobject)? That would ensure that things work properly. But you don't need a whole kobject, just use a named group and a subdir will be created properly for you. good luck, greg k-h