From patchwork Mon Jul 27 21:04:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 6876721 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1881D9F38B for ; Mon, 27 Jul 2015 21:05:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25A4A20709 for ; Mon, 27 Jul 2015 21:05:07 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2256A206C0 for ; Mon, 27 Jul 2015 21:05:06 +0000 (UTC) Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6RL4pJC017214 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 27 Jul 2015 21:04:52 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t6RL4nIx025186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Jul 2015 21:04:50 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1ZJpZp-0001sq-G3; Mon, 27 Jul 2015 14:04:49 -0700 Received: from aserv0022.oracle.com ([141.146.126.234]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1ZJpZC-0001oU-Cr for ocfs2-devel@oss.oracle.com; Mon, 27 Jul 2015 14:04:10 -0700 Received: from aserp1020.oracle.com (aserp1020.oracle.com [141.146.126.67]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t6RL48pI027085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 27 Jul 2015 21:04:08 GMT Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserp1020.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6RL48se025171 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 27 Jul 2015 21:04:08 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.15.0.59/8.15.0.59) with SMTP id t6RL483Y028538 for ; Mon, 27 Jul 2015 21:04:08 GMT Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) by userp2040.oracle.com with ESMTP id 1vwujgag54-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Jul 2015 21:04:07 +0000 Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 637A33EE; Mon, 27 Jul 2015 21:04:06 +0000 (UTC) Date: Mon, 27 Jul 2015 14:04:05 -0700 From: Andrew Morton To: Dan Carpenter Message-Id: <20150727140405.c8281f48d81bd33c6ef957a8@linux-foundation.org> In-Reply-To: <20150727082723.GA3310@mwanda> References: <20150727082723.GA3310@mwanda> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-ServerName: mail.linuxfoundation.org X-Proofpoint-Virus-Version: vendor=nai engine=5700 definitions=7875 signatures=670614 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1506180000 definitions=main-1507270344 Cc: Mark Fasheh , kernel-janitors@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: Re: [Ocfs2-devel] [patch -next] ocfs2: scheduling in atomic in ocfs2_filecheck_store() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: userv0021.oracle.com [156.151.31.71] X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, 27 Jul 2015 11:27:23 +0300 Dan Carpenter wrote: > We're hold "spin_lock(&ent->fs_fcheck->fc_lock)" so the allocation has > to be GFP_ATOMIC. > > I changed the sizeof() because otherwise the line goes over the 80 > character limit and also the new way is prefered kernel style. > > Fixes: e467fe5da718 ('ocfs2: sysfile interfaces for online file check') > Signed-off-by: Dan Carpenter > > diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c > index 3332af1..9613663 100644 > --- a/fs/ocfs2/filecheck.c > +++ b/fs/ocfs2/filecheck.c > @@ -544,7 +544,7 @@ static ssize_t ocfs2_filecheck_store(struct kobject *kobj, > BUG_ON(!ocfs2_filecheck_erase_entry(ent)); > } > > - entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS); > + entry = kmalloc(sizeof(*entry), GFP_ATOMIC); > if (entry) { > entry->fe_ino = args.fa_ino; > entry->fe_type = args.fa_type; GFP_NOFS is more reliable than GFP_ATOMIC, so we should retain that if possible. And it's pretty easy to do here. Gang, please carefully review and test? --- a/fs/ocfs2/filecheck.c~ocfs2-sysfile-interfaces-for-online-file-check-fix-2 +++ a/fs/ocfs2/filecheck.c @@ -501,7 +501,7 @@ static ssize_t ocfs2_filecheck_store(str const char *buf, size_t count) { struct ocfs2_filecheck_args args; - struct ocfs2_filecheck_entry *entry = NULL; + struct ocfs2_filecheck_entry *entry; struct ocfs2_filecheck_sysfs_entry *ent; ssize_t ret = 0; @@ -527,12 +527,19 @@ static ssize_t ocfs2_filecheck_store(str return (!ret ? count : ret); } + entry = kmalloc(sizeof(*entry), GFP_NOFS); + if (!entry) { + ret = -ENOMEM; + goto out; + } + spin_lock(&ent->fs_fcheck->fc_lock); if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) && - (ent->fs_fcheck->fc_done == 0)) { - mlog(ML_ERROR, - "Online file check queue(%u) is full\n", - ent->fs_fcheck->fc_max); + (ent->fs_fcheck->fc_done == 0)) { + mlog(ML_ERROR, "Online file check queue(%u) is full\n", + ent->fs_fcheck->fc_max); + kfree(entry); + entry = NULL; ret = -EBUSY; } else { if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) && @@ -544,26 +551,21 @@ static ssize_t ocfs2_filecheck_store(str BUG_ON(!ocfs2_filecheck_erase_entry(ent)); } - entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS); - if (entry) { - entry->fe_ino = args.fa_ino; - entry->fe_type = args.fa_type; - entry->fe_done = 0; - entry->fe_status = OCFS2_FILECHECK_ERR_INPROGRESS; - list_add_tail(&entry->fe_list, - &ent->fs_fcheck->fc_head); - - ent->fs_fcheck->fc_size++; - ret = count; - } else { - ret = -ENOMEM; - } + entry->fe_ino = args.fa_ino; + entry->fe_type = args.fa_type; + entry->fe_done = 0; + entry->fe_status = OCFS2_FILECHECK_ERR_INPROGRESS; + list_add_tail(&entry->fe_list, &ent->fs_fcheck->fc_head); + + ent->fs_fcheck->fc_size++; + ret = count; } spin_unlock(&ent->fs_fcheck->fc_lock); if (entry) ocfs2_filecheck_handle_entry(ent, entry); +out: ocfs2_filecheck_sysfs_put(ent); return ret; }