From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbbL1Um7 (ORCPT ); Mon, 28 Dec 2015 15:42:59 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:33941 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729AbbL1Umw (ORCPT ); Mon, 28 Dec 2015 15:42:52 -0500 From: Nicolai Stange To: Rajat Jain Cc: "linux-kernel\@vger.kernel.org" , linux-newbie@vger.kernel.org, Greg Kroah-Hartman Subject: Re: debugfs_remove_recursive() while a file is in use by userspace References: Date: Mon, 28 Dec 2015 21:42:49 +0100 In-Reply-To: (Rajat Jain's message of "Mon, 28 Dec 2015 12:27:22 -0800") Message-ID: <87poxqqp86.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rajat, Rajat Jain writes: > 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). > > Does the function wait > > (1) until all the currently executing file operation methods > (read/write/map etc) have returned? > 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)? The current state is that both question are to be answered with "no", i.e. debugfs file removal is racy. I've recently sent a patch addressing this issue: https://lkml.kernel.org/g/87y4dfukzy.fsf@gmail.com Basically, it turns the answer to your first question into "yes". Subsequent reads/writes will return a -EIO. That patch (series) is still under review though. Further reference can be found in the *sub*-thread rooted at http://thread.gmane.org/gmane.linux.kernel/1452470/focus=1467314 Best, Nicolai