From patchwork Thu Jan 12 03:49:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 714177 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tzWxL3H72z9t1L for ; Thu, 12 Jan 2017 14:50:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=thunk.org header.i=@thunk.org header.b="Yax1Xb1p"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752725AbdALDuK (ORCPT ); Wed, 11 Jan 2017 22:50:10 -0500 Received: from imap.thunk.org ([74.207.234.97]:37334 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752557AbdALDt5 (ORCPT ); Wed, 11 Jan 2017 22:49:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=0S2xnFfE7Jz6tE0mr8yJiXhrB1kvJ9yeU+FhVXTtOYI=; b=Yax1Xb1pKZ5n//obZTd4BXZPUYrED4wTC/W7UtYFnTTDSRzmEpH7Dz/6INHOhyBq55wJfixVXZKpn201cBJUPvgPYyKH3FCVKdZwAcWpjCVraO6rqc2Mzlw7BlvH7qYql6N7NiDq3XZD32GacyECM3tYz0ZKYOwZXCaJ0rMKZ8w=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.84_2) (envelope-from ) id 1cRWOi-0005Kk-Qf; Thu, 12 Jan 2017 03:49:56 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id 05178C00750; Wed, 11 Jan 2017 22:49:55 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List Cc: linux@sciencehorizons.net, Theodore Ts'o Subject: [PATCH 3/4] ext4: avoid calling ext4_mark_inode_dirty() under unneeded semaphores Date: Wed, 11 Jan 2017 22:49:37 -0500 Message-Id: <20170112034938.5934-5-tytso@mit.edu> X-Mailer: git-send-email 2.11.0.rc0.7.gbe5a750 In-Reply-To: <20170112034938.5934-1-tytso@mit.edu> References: <20170112034938.5934-1-tytso@mit.edu> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org There is no need to call ext4_mark_inode_dirty while holding xattr_sem or i_data_sem, so where it's easy to avoid it, move it out from the critical region. Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara --- fs/ext4/inline.c | 9 +++------ fs/ext4/inode.c | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 99a5312ced52..31f98dd04e51 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1042,7 +1042,6 @@ static int ext4_add_dirent_to_inline(handle_t *handle, dir->i_mtime = dir->i_ctime = current_time(dir); ext4_update_dx_flag(dir); dir->i_version++; - ext4_mark_inode_dirty(handle, dir); return 1; } @@ -1311,8 +1310,8 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname, ret = ext4_convert_inline_data_nolock(handle, dir, &iloc); out: - ext4_mark_inode_dirty(handle, dir); ext4_write_unlock_xattr(dir, &no_expand); + ext4_mark_inode_dirty(handle, dir); brelse(iloc.bh); return ret; } @@ -1708,13 +1707,11 @@ int ext4_delete_inline_entry(handle_t *handle, if (err) goto out; - err = ext4_mark_inode_dirty(handle, dir); - if (unlikely(err)) - goto out; - ext4_show_inline_dir(dir, iloc.bh, inline_start, inline_size); out: ext4_write_unlock_xattr(dir, &no_expand); + if (likely(err == 0)) + err = ext4_mark_inode_dirty(handle, dir); brelse(iloc.bh); if (err != -ENOENT) ext4_std_error(dir->i_sb, err); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 88d57af1b516..86dde0667ccc 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2464,8 +2464,8 @@ static int mpage_map_and_submit_extent(handle_t *handle, disksize = i_size; if (disksize > EXT4_I(inode)->i_disksize) EXT4_I(inode)->i_disksize = disksize; - err2 = ext4_mark_inode_dirty(handle, inode); up_write(&EXT4_I(inode)->i_data_sem); + err2 = ext4_mark_inode_dirty(handle, inode); if (err2) ext4_error(inode->i_sb, "Failed to mark inode %lu dirty",