From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbbL1Ubq (ORCPT ); Mon, 28 Dec 2015 15:31:46 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:40786 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752468AbbL1Ubn (ORCPT ); Mon, 28 Dec 2015 15:31:43 -0500 X-Sasl-enc: QM2hh1FZOOOum4MKpFSWLBcQIrydUa5XL+RqGEDcebbK 1451334702 Date: Mon, 28 Dec 2015 12:31:21 -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: <20151228203121.GA19753@kroah.com> References: 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:27:22PM -0800, Rajat Jain wrote: > Hi, > > I wanted to understand the behavior taken when a module calls > debugfs_remove_recursive() on a directory, while files under that > directory may still be in use by the userspace (for instance an > ongoing read / write operation). Bad things :( > Does the function wait > > (1) until all the currently executing file operation methods > (read/write/map etc) have returned? Nope. > OR > (2) until the user has given up all references (descriptors) to the > files under the directory (i.e. until release() method has been > called)? Nope. There are some patches on the mailing list that I need to review that hopefully should resolve this problem, as it's been known for a very long time. In short, just don't remove debugfs files unless your module is unloading, and all should be good as modules are never auto-unloaded. If you remove debugfs files when a device is removed, be careful. thanks, greg k-h