Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp811332ybl; Fri, 9 Aug 2019 14:20:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqydP86uI+zv2rUZkRJY0Grslbsru7raooiLDrVJuvgry6lfxWTYQjzGIsvBhsbyLiGPbB8z X-Received: by 2002:aa7:957c:: with SMTP id x28mr23556566pfq.42.1565385646065; Fri, 09 Aug 2019 14:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565385646; cv=none; d=google.com; s=arc-20160816; b=uC1VJLDk97SmFDEhqirsA+aQILRweVOV7JB2+gWH5vUZrF5mXe0JuC85qi7ywdTTgi X0yiDgWkMcL9FdSKQ8PNKydyrAT0d/GePsztBPbeOK2BMi3bfxC7ThHhM25UWPocUtSk WIApWm/6jvJSASzJE7FSkSjv3nEWrQyz80no6X4e7IfRsWu8qiKuVRSg/iB8Xr63AaXK fdyAuA2Gg1zdFJwimf2AysuplAkk35IxdFwiswWPeYEIToLd6dCTQxMSBglYZ95c00dQ XOOJnybh5nSn5q13vYqbUY9RaX2AIiEmnPdP+auHB86C+ZbB1Euv0UDuH3XPHUdZ7llU RqUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pCxfpYfrohJOa/YQNK7w4lvqmXX/vmz1SK0u4S/kd18=; b=O6sSe8kRXcK1Q7KFbqpxbLsBwfqDM9XYK5E5wpxsseDlyhSqDyjgJ1eO6UB2fmQ2az Pb75c/fD+Z4q6fUL71SIZITuGV07YV9QCTuO73wfpZ1envEEPVnHS9obUh4RPhJJRK5t N6NWTqt8DvGXgSdTYuPFERAB+Bdf3jME1wMu1At1rn57OOLnFPQqnorrAW9X4Hu2MDJR 3WEyCa1pAsJVGwpvOEL4FGNeQ2XC/QS2zo/T4aYO/5AJFSn0SrikURO1fMyXUXpPw5JP /tCcU0ClKgeIHMGuxBVbkBcr2JjORMSEtx+py5NNOqLgtwTPErbLm7ZGzdMt5hsjDYhs L7nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T9uIddpw; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si21814568pgk.309.2019.08.09.14.20.31; Fri, 09 Aug 2019 14:20: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T9uIddpw; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbfHIVUW (ORCPT + 99 others); Fri, 9 Aug 2019 17:20:22 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:39479 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfHIVUW (ORCPT ); Fri, 9 Aug 2019 17:20:22 -0400 Received: by mail-ot1-f66.google.com with SMTP id r21so131965471otq.6 for ; Fri, 09 Aug 2019 14:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pCxfpYfrohJOa/YQNK7w4lvqmXX/vmz1SK0u4S/kd18=; b=T9uIddpw3msyHWGu627JvjR4zZZUgHzJ3u8pW06kGpAQU7g/5ZH8+aQGbKP0nWQdM3 4sPkJwYhieAEHOyzgLeTkUifoKon3YY+0jbm5HYHGL+h9y2F3tKZPwm+bqtprq4Vo0PF BG0SKnLbw0UnIpkndrm4dx9oPvb351spsF3VmDTwnejJZanbeWvMzAV8a0b4nbKOX+fo CeiOpjUBsSk1VB3G/Nd7pb+kjhP90FwCEyVOXPOBdGxqohbf+WuaQCzF+6hGzvaCnCk5 +F4UFG12AlcVbNfawRWePbFmngemekhEWq7tBEuRnDEkKmRVY0Wj+NT7fpiwZ74gzFYe CFcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pCxfpYfrohJOa/YQNK7w4lvqmXX/vmz1SK0u4S/kd18=; b=DYhR42Zd9RgshWpvfhU9Gy68QsW3heJFirValzbaEDPjaywPksXXNtKV2XUPA6lj5U j7rMrKZoDRpx2gplkDq4y/zdJE/JRnjS61kmzoueaOw9ju8SvWYISBzpuHk6VuGLinM+ 5D3vSEHx19Sb654noHYSOhoJcuFImYKI7zSRwjojkHbOlvkQL+CUbuEWvd1g8GYuqdDZ oaNzr8TrQwJ+9DMdHnNQNTouRMJItRn3pby7CklXDyWlNxdytp5B1IHnNt/4QTdECF08 KsQYt8jTx/1FoqzKwBWjwUUUBRHG42c8/uN2q2AFMYq7D+QUtAdwBWRdhgtxE88/2wMs J6XQ== X-Gm-Message-State: APjAAAXyxuGywkarCNFtGyvbK9v7HtyhXAmFckrqMy+QhrkFkPquXl8q POtsd54lWGVAGT+bNfubkIukPtNXpV/F8S4CotGDNEzu X-Received: by 2002:a9d:7248:: with SMTP id a8mr20452744otk.363.1565385620624; Fri, 09 Aug 2019 14:20:20 -0700 (PDT) MIME-Version: 1.0 References: <20190809034552.148629-1-harshadshirwadkar@gmail.com> <20190809034552.148629-6-harshadshirwadkar@gmail.com> <6DBCC366-02CC-4F2A-AA16-EC4587261699@dilger.ca> In-Reply-To: From: harshad shirwadkar Date: Fri, 9 Aug 2019 14:20:09 -0700 Message-ID: Subject: Re: [PATCH v2 05/12] jbd2: fast-commit commit path new APIs To: Andreas Dilger Cc: Ext4 Developers List Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Aug 9, 2019 at 2:11 PM Andreas Dilger wrote: > > > > On Aug 9, 2019, at 2:38 PM, Andreas Dilger wrote: > > > > On Aug 8, 2019, at 9:45 PM, Harshad Shirwadkar wrote: > >> > >> This patch adds new helper APIs that ext4 needs for fast > >> commits. These new fast commit APIs are used by subsequent fast commit > >> patches to implement fast commits. Following new APIs are added: > >> > >> /* > >> * Returns when either a full commit or a fast commit > >> * completes > >> */ > >> int jbd2_fc_complete_commit(journal_tc *journal, tid_t tid, > >> tid_t tid, tid_t subtid) > >> > >> /* Send all the data buffers related to an inode */ > >> int journal_submit_inode_data(journal_t *journal, > >> struct jbd2_inode *jinode) > >> > >> /* Map one fast commit buffer for use by the file system */ > >> int jbd2_map_fc_buf(journal_t *journal, struct buffer_head **bh_out) > >> > >> /* Wait on fast commit buffers to complete IO */ > >> jbd2_wait_on_fc_bufs(journal_t *journal, int num_bufs) > >> > >> Signed-off-by: Harshad Shirwadkar > >> > >> +int jbd2_map_fc_buf(journal_t *journal, struct buffer_head **bh_out) > >> +{ > >> + unsigned long long pblock; > >> + unsigned long blocknr; > >> + int ret = 0; > >> + struct buffer_head *bh; > >> + int fc_off; > >> + journal_header_t *jhdr; > >> + > >> + write_lock(&journal->j_state_lock); > >> + > >> + if (journal->j_fc_off + journal->j_first_fc < journal->j_last_fc) { > >> + fc_off = journal->j_fc_off; > >> + blocknr = journal->j_first_fc + fc_off; > >> + journal->j_fc_off++; > >> + } else { > >> + ret = -EINVAL; > >> + } > >> + write_unlock(&journal->j_state_lock); > >> + > >> + if (ret) > >> + return ret; > >> + > >> + ret = jbd2_journal_bmap(journal, blocknr, &pblock); > >> + if (ret) > >> + return ret; > >> + > >> + bh = __getblk(journal->j_dev, pblock, journal->j_blocksize); > >> + if (!bh) > >> + return -ENOMEM; > >> + > >> + lock_buffer(bh); > >> + jhdr = (journal_header_t *)bh->b_data; > >> + jhdr->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); > >> + jhdr->h_blocktype = cpu_to_be32(JBD2_FC_BLOCK); > >> + jhdr->h_sequence = cpu_to_be32(journal->j_running_transaction->t_tid); > >> + > >> + set_buffer_uptodate(bh); > >> + unlock_buffer(bh); > >> + journal->j_fc_wbuf[fc_off] = bh; > >> + > >> + *bh_out = bh; > >> + > >> + return 0; > >> +} > >> +EXPORT_SYMBOL(jbd2_map_fc_buf); > > One question about this function. It seems that it is called for every > commit by ext4_journal_fc_commit_cb(). Why does it need to map the fast > journal commit blocks on every call? It would make more sense to map the > blocks once at initialization time and then just re-use them on each call. > The only reason why I did it this way is that this way JBD2 gets an opportunity to set-up journal header at the beginning of the block which contains TID information. But I guess we could have a separate call for setting the journal header and ext4 could call that routine instead of mapping buffers on every commit call. Thanks for pointing this out. I'll fix this in V3. > Cheers, Andreas > > > > >