Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7204120ybp; Wed, 16 Oct 2019 05:26:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz79JILvjdsn/IyNqkXgA7ZEqxymg9pS30YZLW253l7RiF4zLafzVbfU0dNJfn4oG3ptjAS X-Received: by 2002:a17:906:bcdc:: with SMTP id lw28mr39587820ejb.183.1571228806340; Wed, 16 Oct 2019 05:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571228806; cv=none; d=google.com; s=arc-20160816; b=Yx7lUOLLEElr8Zy5v6i5qEItVywZxstgjJXP4HRFyFtkOG8VBSgiXnnJ5u8ujQrI5S oVe4nDJ0wwcO8cAylSAkHV2TddCxhuE6JRKpyfzQgZ89V0wB2KpJOgsXy3zcLxxyh0rs 0qaEg3SgIzCD6JIrOsB5ZV+ubk/L90MkaOSeE9qrU6Z9NKTAu+DyI/UstB+suTpi+RnE Q+jG2iAF/jTY+yKF++yDnbNydVvQtP92Kjs/qEIMDxqYMgcQRmW2N0tm6+h62rQmD2xe /5gAgptt0Z9X7hbOBrNUoImhUOUOFs8YwLROamoOHMy62BLgk+EucD3SI6ROF6vRu1DO +7ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=noJloOzYDmmYmW9wgkSicnQ6BD4933VU4XaMRwVpPaA=; b=SekDR0P9LrmJn3X7pqCuI6khHwKK8y4+L0l35APQI4gWnUYIUHj+8vEGncCA+4aItV z1bhEVXx1CJe3rRtdJhjBhantwJmoOWDUBJm1IZlaWdPqBJMBcNvZuJrnSX5ixyIsqwl C8CIrOeB3+5j3ZEQ0gCD2VohkXx+6Ui3VGnBm7LWNdP6miMPRLphjGpn6OesAQGtgCWw NmMN5o0EofZU1F7RSfjyR53XeNmy57XJAmtmcqsBgdTt5kl6IhtCkA9gXpiqSOzgkGr3 s2ORi4iuhY9Ubz0OCAUM51FXTc1YAfUSeOHwr6pztNYkH8ec/quf335nPAGOifl8Rd6+ pySg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qo6si15493386ejb.386.2019.10.16.05.26.16; Wed, 16 Oct 2019 05:26:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732738AbfJPHh1 (ORCPT + 99 others); Wed, 16 Oct 2019 03:37:27 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:13728 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730414AbfJPHh1 (ORCPT ); Wed, 16 Oct 2019 03:37:27 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x9G7b8t8082192 for ; Wed, 16 Oct 2019 03:37:26 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vnuq1x6n4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 16 Oct 2019 03:37:26 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Oct 2019 08:37:24 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 16 Oct 2019 08:37:21 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x9G7bK1e53084230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2019 07:37:21 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8863AE04D; Wed, 16 Oct 2019 07:37:20 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75EAEAE053; Wed, 16 Oct 2019 07:37:19 +0000 (GMT) Received: from dhcp-9-199-158-105.in.ibm.com (unknown [9.199.158.105]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 16 Oct 2019 07:37:18 +0000 (GMT) From: Ritesh Harjani To: tytso@mit.edu, jack@suse.cz, linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, mbobrowski@mbobrowski.org, riteshh@linux.ibm.com Subject: [RFC 2/5] ext4: Add API to bring in support for unwritten io_end_vec conversion Date: Wed, 16 Oct 2019 13:07:08 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016073711.4141-1-riteshh@linux.ibm.com> References: <20191016073711.4141-1-riteshh@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19101607-0008-0000-0000-000003227AA4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19101607-0009-0000-0000-00004A4192F1 Message-Id: <20191016073711.4141-3-riteshh@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-16_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910160071 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch just brings in the API for conversion of unwritten io_end_vec extents which will be required for blocksize < pagesize support for dioread_nolock feature. No functional changes in this patch. Signed-off-by: Ritesh Harjani --- fs/ext4/ext4.h | 2 ++ fs/ext4/extents.c | 42 +++++++++++++++++++++++++++--------------- fs/ext4/page-io.c | 7 +++---- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 03db3e71676c..8d924bd19ca7 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3264,6 +3264,8 @@ extern long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len); extern int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode, loff_t offset, ssize_t len); +extern int ext4_convert_unwritten_io_end_vec(handle_t *handle, + ext4_io_end_t *io_end); extern int ext4_map_blocks(handle_t *handle, struct inode *inode, struct ext4_map_blocks *map, int flags); extern int ext4_ext_calc_metadata_amount(struct inode *inode, diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index fb0f99dc8c22..731e67ccab22 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4962,23 +4962,13 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode, int ret = 0; int ret2 = 0; struct ext4_map_blocks map; - unsigned int credits, blkbits = inode->i_blkbits; + unsigned int blkbits = inode->i_blkbits; + unsigned int credits = 0; map.m_lblk = offset >> blkbits; max_blocks = EXT4_MAX_BLOCKS(len, offset, blkbits); - /* - * This is somewhat ugly but the idea is clear: When transaction is - * reserved, everything goes into it. Otherwise we rather start several - * smaller transactions for conversion of each extent separately. - */ - if (handle) { - handle = ext4_journal_start_reserved(handle, - EXT4_HT_EXT_CONVERT); - if (IS_ERR(handle)) - return PTR_ERR(handle); - credits = 0; - } else { + if (!handle) { /* * credits to insert 1 extent into extent tree */ @@ -5009,11 +4999,33 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode, if (ret <= 0 || ret2) break; } - if (!credits) - ret2 = ext4_journal_stop(handle); return ret > 0 ? ret2 : ret; } +int ext4_convert_unwritten_io_end_vec(handle_t *handle, ext4_io_end_t *io_end) +{ + int ret, err = 0; + + /* + * This is somewhat ugly but the idea is clear: When transaction is + * reserved, everything goes into it. Otherwise we rather start several + * smaller transactions for conversion of each extent separately. + */ + if (handle) { + handle = ext4_journal_start_reserved(handle, + EXT4_HT_EXT_CONVERT); + if (IS_ERR(handle)) + return PTR_ERR(handle); + } + + ret = ext4_convert_unwritten_extents(handle, io_end->inode, + io_end->offset, io_end->size); + if (handle) + err = ext4_journal_stop(handle); + + return ret < 0 ? ret : err; +} + /* * If newes is not existing extent (newes->ec_pblk equals zero) find * delayed extent at start of newes and update newes accordingly and diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index d9b96fc976a3..3ccf54a380b2 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -149,7 +149,7 @@ static int ext4_end_io_end(ext4_io_end_t *io_end) io_end, inode->i_ino, io_end->list.next, io_end->list.prev); io_end->handle = NULL; /* Following call will use up the handle */ - ret = ext4_convert_unwritten_extents(handle, inode, offset, size); + ret = ext4_convert_unwritten_io_end_vec(handle, io_end); if (ret < 0 && !ext4_forced_shutdown(EXT4_SB(inode->i_sb))) { ext4_msg(inode->i_sb, KERN_EMERG, "failed to convert unwritten extents to written " @@ -269,9 +269,8 @@ int ext4_put_io_end(ext4_io_end_t *io_end) if (atomic_dec_and_test(&io_end->count)) { if (io_end->flag & EXT4_IO_END_UNWRITTEN) { - err = ext4_convert_unwritten_extents(io_end->handle, - io_end->inode, io_end->offset, - io_end->size); + err = ext4_convert_unwritten_io_end_vec(io_end->handle, + io_end); io_end->handle = NULL; ext4_clear_io_unwritten_flag(io_end); } -- 2.21.0