From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755754AbbINNtp (ORCPT ); Mon, 14 Sep 2015 09:49:45 -0400 Received: from mail-yk0-f178.google.com ([209.85.160.178]:36150 "EHLO mail-yk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942AbbINNqE (ORCPT ); Mon, 14 Sep 2015 09:46:04 -0400 From: Jeff Layton X-Google-Original-From: Jeff Layton To: Al Viro Cc: bfields@fieldses.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] fs: add fput_queue Date: Mon, 14 Sep 2015 09:45:54 -0400 Message-Id: <1442238355-8203-4-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442238355-8203-1-git-send-email-jeff.layton@primarydata.com> References: <1442238355-8203-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Jeff Layton --- fs/file_table.c | 18 ++++++++++++++++++ include/linux/file.h | 1 + 2 files changed, 19 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index d63f4a399d39..1ad2e3fd2064 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -297,6 +297,24 @@ void fput(struct file *file) } EXPORT_SYMBOL(fput); +/** + * fput_queue - do an fput without using task_work + * @file: file of which to put the reference + * + * If we need to ensure that the final __fput is done on a file before + * returning to userland, then we can't queue it to task_work. For that we + * borrow the infrastructure used by kthreads, and the task can then just + * called flush_delayed_fput to ensure that the final fput has completed. + */ +void fput_queue(struct file *file) +{ + if (atomic_long_dec_and_test(&file->f_count)) { + if (llist_add(&file->f_u.fu_llist, &delayed_fput_list)) + schedule_delayed_work(&delayed_fput_work, 1); + } +} +EXPORT_SYMBOL(fput_queue); + /* * synchronous analog of fput(); for kernel threads that might be needed * in some umount() (and thus can't use flush_delayed_fput() without diff --git a/include/linux/file.h b/include/linux/file.h index f87d30882a24..543b0e2faf2c 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -12,6 +12,7 @@ struct file; extern void fput(struct file *); +extern void fput_queue(struct file *); struct file_operations; struct vfsmount; -- 2.4.3 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton Subject: [PATCH 3/4] fs: add fput_queue Date: Mon, 14 Sep 2015 09:45:54 -0400 Message-ID: <1442238355-8203-4-git-send-email-jeff.layton@primarydata.com> References: <1442238355-8203-1-git-send-email-jeff.layton@primarydata.com> Cc: bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org, linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Al Viro Return-path: In-Reply-To: <1442238355-8203-1-git-send-email-jeff.layton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org> Sender: linux-nfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org Signed-off-by: Jeff Layton --- fs/file_table.c | 18 ++++++++++++++++++ include/linux/file.h | 1 + 2 files changed, 19 insertions(+) diff --git a/fs/file_table.c b/fs/file_table.c index d63f4a399d39..1ad2e3fd2064 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -297,6 +297,24 @@ void fput(struct file *file) } EXPORT_SYMBOL(fput); +/** + * fput_queue - do an fput without using task_work + * @file: file of which to put the reference + * + * If we need to ensure that the final __fput is done on a file before + * returning to userland, then we can't queue it to task_work. For that we + * borrow the infrastructure used by kthreads, and the task can then just + * called flush_delayed_fput to ensure that the final fput has completed. + */ +void fput_queue(struct file *file) +{ + if (atomic_long_dec_and_test(&file->f_count)) { + if (llist_add(&file->f_u.fu_llist, &delayed_fput_list)) + schedule_delayed_work(&delayed_fput_work, 1); + } +} +EXPORT_SYMBOL(fput_queue); + /* * synchronous analog of fput(); for kernel threads that might be needed * in some umount() (and thus can't use flush_delayed_fput() without diff --git a/include/linux/file.h b/include/linux/file.h index f87d30882a24..543b0e2faf2c 100644 --- a/include/linux/file.h +++ b/include/linux/file.h @@ -12,6 +12,7 @@ struct file; extern void fput(struct file *); +extern void fput_queue(struct file *); struct file_operations; struct vfsmount; -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html