From patchwork Mon May 11 18:03:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 11541407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 451CE912 for ; Mon, 11 May 2020 18:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35056206B9 for ; Mon, 11 May 2020 18:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731061AbgEKSDj (ORCPT ); Mon, 11 May 2020 14:03:39 -0400 Received: from mailrelay107.isp.belgacom.be ([195.238.20.134]:58693 "EHLO mailrelay107.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbgEKSDj (ORCPT ); Mon, 11 May 2020 14:03:39 -0400 IronPort-SDR: VUq4jO75KW4H3TgsSOFgBFUo9vAEUdMNiSd5BWXN7y18LYE7ofKn66OXrim0BUh82D5eNZjRca f06kf1ferT2TBmt785tOOesjePmPcSZv5NQrw9iHAPRF36soHC85WyyQ1GqEwGysj5Mg1zyxFW pVTpxrmEkWRxgwEyR8WnV4Ow/40jghhQs2Kp1A1Mf//y/9Z3YbpgseKsUq3HTnNx2sP7jdBUEy rg0A421F+Pk0unSujCPB0jeXS6ivyTFVOcQpziXnaogGG54tmG1faJkWxNjDqmy897kEwGG2o4 +lA= X-Belgacom-Dynamic: yes IronPort-PHdr: 9a23:ZUoO0hJEWyVjs6zkjdmcpTZWNBhigK39O0sv0rFitYgfLvTxwZ3uMQTl6Ol3ixeRBMOHsq8C2rKd6vm7EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5p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syKWVCrXpOsDGdiHZoK39YSbhMlSJ2ZhRfZ0n/yDg== X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BLBwAhk7le/xCltltmhHqBZBIsjSWFeowYijKHJgsBAQEBAQEBAQE0AQIEAQGERIINJzgTAgMBAQEDAgUBAQYBAQEBAQEEBAFsBAEBBwoCAYROIQEDAQEFCgFDgjsig0ILASMjT3ASgyaCWCmwRDOFUYNXgUCBOIddhQGBQT+EX4QGhjwEjkakJYJUgnGVKwwdnTotj3CfOyKBVk0gGDuCaVAYDZBMF44nQjA3AgYIAQEDCVcBIgGLVII0AQE X-IPAS-Result: A2BLBwAhk7le/xCltltmhHqBZBIsjSWFeowYijKHJgsBAQEBAQEBAQE0AQIEAQGERIINJzgTAgMBAQEDAgUBAQYBAQEBAQEEBAFsBAEBBwoCAYROIQEDAQEFCgFDgjsig0ILASMjT3ASgyaCWCmwRDOFUYNXgUCBOIddhQGBQT+EX4QGhjwEjkakJYJUgnGVKwwdnTotj3CfOyKBVk0gGDuCaVAYDZBMF44nQjA3AgYIAQEDCVcBIgGLVII0AQE Received: from 16.165-182-91.adsl-dyn.isp.belgacom.be (HELO biggussolus.home) ([91.182.165.16]) by relay.skynet.be with ESMTP; 11 May 2020 20:03:16 +0200 From: Fabian Frederick To: jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 9/9 linux-next] fsnotify: fsnotify_clear_marks_by_group() massage Date: Mon, 11 May 2020 20:03:05 +0200 Message-Id: <20200511180305.215252-1-fabf@skynet.be> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org revert condition and remove clear label Signed-off-by: Fabian Frederick --- fs/notify/mark.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 1d96216dffd1..ca2eba786bb6 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -724,28 +724,27 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group, LIST_HEAD(to_free); struct list_head *head = &to_free; - /* Skip selection step if we want to clear all marks. */ - if (type_mask == FSNOTIFY_OBJ_ALL_TYPES_MASK) { + if (type_mask != FSNOTIFY_OBJ_ALL_TYPES_MASK) { + /* + * We have to be really careful here. Anytime we drop mark_mutex, + * e.g. fsnotify_clear_marks_by_inode() can come and free marks. + * Even in our to_free list so we have to use mark_mutex even + * when accessing that list. And freeing mark requires us to drop + * mark_mutex. So we can reliably free only the first mark in the + * list. That's why we first move marks to free to to_free list + * in one go and then free marks in to_free list one by one. + */ + mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING); + list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) { + if ((1U << mark->connector->type) & type_mask) + list_move(&mark->g_list, &to_free); + } + mutex_unlock(&group->mark_mutex); + } else { + /* Skip selection step if we want to clear all marks. */ head = &group->marks_list; - goto clear; } - /* - * We have to be really careful here. Anytime we drop mark_mutex, e.g. - * fsnotify_clear_marks_by_inode() can come and free marks. Even in our - * to_free list so we have to use mark_mutex even when accessing that - * list. And freeing mark requires us to drop mark_mutex. So we can - * reliably free only the first mark in the list. That's why we first - * move marks to free to to_free list in one go and then free marks in - * to_free list one by one. - */ - mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING); - list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) { - if ((1U << mark->connector->type) & type_mask) - list_move(&mark->g_list, &to_free); - } - mutex_unlock(&group->mark_mutex); -clear: while (1) { mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING); if (list_empty(head)) {