Received: by 10.223.164.202 with SMTP id h10csp4292359wrb; Wed, 29 Nov 2017 04:11:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMaYC+vkFzbAPZIZVlGqLu5gDtYwsjCgD0ti3xTMw1Dlcf+Y/QSV6L3C7G28OmoH7rSa6TP4 X-Received: by 10.84.130.97 with SMTP id 88mr2740880plc.131.1511957517734; Wed, 29 Nov 2017 04:11:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511957517; cv=none; d=google.com; s=arc-20160816; b=DZV/QccaNji/+5Sjdjnb/tj8KymSjBflFmtGZ8tDPXKw888FYmN2/g5Qdr63qEp3/U O0d9JbVKD1Q9FbWpjcuXTJ0qdNCBpyZUov5Z+rCDWp+o+yjjBBSO+7/xxYTmVE+1c8TQ 8ceNI7LlDNXTE49l5cvd6+dSV1bEXkX8qlLoD3L1Kv8nKgCugDCOEu9Vjk5pTCuoFzvK xfzNYlxd2UcMp4E3ORwNpo+X/3BOxQwYkMpkGYXxs1QHNQoQypooK0yOUqJPa4TMSmni oTY3cREG3eInMY1vw/aAeiIxl1y935teDpsKs7UdOLpwryMlTuTX3gQ/jaEbCXrRDSoF rPFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=csXCtjxnu65tY/XwuslAaOO7UGQ+kXyjz5XoG5HQTMo=; b=zfKAzaPZ17+WZGF3084NcoUuuiZ5ywUeLJdtbo6EXqkzB3p+6QIEvMV0k27t/LiXTa RQvMXrPqS01oBGZpjXnXLLgyrq7xfabYw967pX+7n5StMtgHXJEnRsSrSU+WMb2X8A4I YbRf8gao7ppAdqJJ78f4YLR3Er6Y4wyZmYgLoPR7SF5jdYSNBVCpcR4vmyraksDWw6Xg wSf1wqy3z8vswz2GzK5EBiqVURSXGq1CG3aGngtWGe43LFGoxul1GS3F5EgN7J2thw3f pSPKCfYuspOCOtSVB25VvuVIKNLLo6tmGHHUqZgEH0UoBV+MrrDZXfCORK4Ae0ez7yQf 6JWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si1114702pgq.737.2017.11.29.04.11.46; Wed, 29 Nov 2017 04:11:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932131AbdK2MJy convert rfc822-to-8bit (ORCPT + 70 others); Wed, 29 Nov 2017 07:09:54 -0500 Received: from smtp.h3c.com ([60.191.123.56]:43194 "EHLO h3cmg01-ex.h3c.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751603AbdK2MJx (ORCPT ); Wed, 29 Nov 2017 07:09:53 -0500 Received: from BJHUB01-EX.srv.huawei-3com.com (unknown [10.63.20.169]) by h3cmg01-ex.h3c.com with smtp id 5d29_019c_2e8d5406_f4f0_4706_ac0e_9455f68eaaa1; Wed, 29 Nov 2017 20:05:14 +0800 Received: from H3CMLB14-EX.srv.huawei-3com.com ([fe80::f804:6772:bd71:f07f]) by BJHUB01-EX.srv.huawei-3com.com ([::1]) with mapi id 14.03.0248.002; Wed, 29 Nov 2017 20:05:01 +0800 From: Changwei Ge To: Gang He , "mfasheh@versity.com" , "jlbec@evilplan.org" , "rgoldwyn@suse.com" , "hch@lst.de" CC: "linux-kernel@vger.kernel.org" , "ocfs2-devel@oss.oracle.com" Subject: Re: [Ocfs2-devel] [PATCH v2 2/3] ocfs2: add ocfs2_overwrite_io function Thread-Topic: [Ocfs2-devel] [PATCH v2 2/3] ocfs2: add ocfs2_overwrite_io function Thread-Index: AQHTaO2fE2MEQ0PYEUaCCMleYFRzFg== Date: Wed, 29 Nov 2017 12:05:00 +0000 Message-ID: <63ADC13FD55D6546B7DECE290D39E373F147DC9A@H3CMLB14-EX.srv.huawei-3com.com> References: <1511944612-9629-1-git-send-email-ghe@suse.com> <1511944612-9629-3-git-send-email-ghe@suse.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.125.136.231] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It looks fine to me. On 2017/11/29 16:39, Gang He wrote: > Add ocfs2_overwrite_io function, which is used to judge if > overwrite allocated blocks, otherwise, the write will bring extra > block allocation overhead. > > Signed-off-by: Gang He Reviewed-by: Changwei Ge > --- > fs/ocfs2/extent_map.c | 41 +++++++++++++++++++++++++++++++++++++++++ > fs/ocfs2/extent_map.h | 3 +++ > 2 files changed, 44 insertions(+) > > diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c > index e4719e0..4da33e9 100644 > --- a/fs/ocfs2/extent_map.c > +++ b/fs/ocfs2/extent_map.c > @@ -832,6 +832,47 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > return ret; > } > > +/* Is IO overwriting allocated blocks? */ > +int ocfs2_overwrite_io(struct inode *inode, struct buffer_head *di_bh, > + u64 map_start, u64 map_len) > +{ > + int ret = 0, is_last; > + u32 mapping_end, cpos; > + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); > + struct ocfs2_extent_rec rec; > + > + if ((OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) && > + ((map_start + map_len) <= i_size_read(inode))) > + goto out; > + > + cpos = map_start >> osb->s_clustersize_bits; > + mapping_end = ocfs2_clusters_for_bytes(inode->i_sb, > + map_start + map_len); > + is_last = 0; > + while (cpos < mapping_end && !is_last) { > + ret = ocfs2_get_clusters_nocache(inode, di_bh, cpos, > + NULL, &rec, &is_last); > + if (ret) { > + mlog_errno(ret); > + goto out; > + } > + > + if (rec.e_blkno == 0ULL) > + break; > + > + if (rec.e_flags & OCFS2_EXT_REFCOUNTED) > + break; > + > + cpos = le32_to_cpu(rec.e_cpos) + > + le16_to_cpu(rec.e_leaf_clusters); > + } > + > + if (cpos < mapping_end) > + ret = -EAGAIN; > +out: > + return ret; > +} > + > int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int whence) > { > struct inode *inode = file->f_mapping->host; > diff --git a/fs/ocfs2/extent_map.h b/fs/ocfs2/extent_map.h > index 67ea57d..1057586 100644 > --- a/fs/ocfs2/extent_map.h > +++ b/fs/ocfs2/extent_map.h > @@ -53,6 +53,9 @@ int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, > int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > u64 map_start, u64 map_len); > > +int ocfs2_overwrite_io(struct inode *inode, struct buffer_head *di_bh, > + u64 map_start, u64 map_len); > + > int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin); > > int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster, > From 1585316369153635664@xxx Tue Nov 28 13:25:04 +0000 2017 X-GM-THRID: 1585212205986077742 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread