Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1634097pxu; Sat, 12 Dec 2020 21:20:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJynTojTV4kVih8BgWB6598Kho8COYEqeNFrEzZFJEX4DzR2JJowinimNcG0CI7xEuQlYJUL X-Received: by 2002:a50:b5c5:: with SMTP id a63mr4368170ede.227.1607836845757; Sat, 12 Dec 2020 21:20:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607836845; cv=none; d=google.com; s=arc-20160816; b=RCS3fJlmluDpH5kK5gcby2ltYW41XzY6K0dVCjfJTYSQAK2u2U7z2IqNOyzM2AA0KR E5Jr84Q565GsnQvGNU6aZWmEv6qynMYBCSFaeTbg0Jx+EGcHjYfzlITngHHBUZRPjEAi HW4dEpRBa0UVBDnEu7+2SkgsCMZvTT5zTqo1KvCkPPX3TcT6JJx7OCO2a61v9HMwTOTR 3PsqgrznnIMaifEVRnaz/A7zCtE3926XuALEzPDi/CBG/7O9ZeO4buvuiF0DPpEDcgmA h/SZ+AR0UjxRnlbTSc1DnPVZPj2l1jwb7Ir4jSebm4rpOQgRCeJQt/K24U5xHlwP7vFX 1m5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=hJ1joTpIWftCALU6uuD+JVaud1EsBeskKydpzuDJ9fw=; b=Apx1F4DtxWLFb8OQL0CPFzSk3YLur8NgPuyn0vlxR7qHWNeMzx4mKdkidklZoA9Zz1 P09EEMYLu18PachP3z3wDVfn8rcs33jegGUYPnK0ch1JSpvyrYgKfRBzuiU2fCnRKQ39 ZrZYfyzdFMO77lgd/nsEUcAD27NfdPCCzUbm84WxsnCD7ZJ7xiHp88zQAlKqNFEUfXeV NnPHIyrCe5gPfkDM0TGiGb5w+lOqSHVuNntlxIpC/UVYg4sJRhv7siJphmZCmp4facSu uHel0M+MK4Lq4WpItLjPEw+t9Bt1gSFplUE/H2JMUR3OlTI3fCMT2K1dYiQDYqKYhFmL QhZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si7391523ejg.677.2020.12.12.21.20.13; Sat, 12 Dec 2020 21:20:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436708AbgLKWgf (ORCPT + 99 others); Fri, 11 Dec 2020 17:36:35 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:49242 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727605AbgLKWgG (ORCPT ); Fri, 11 Dec 2020 17:36:06 -0500 Received: from callcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 0BBMZD2s019961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Dec 2020 17:35:13 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id D558F420136; Fri, 11 Dec 2020 17:35:12 -0500 (EST) Date: Fri, 11 Dec 2020 17:35:12 -0500 From: "Theodore Y. Ts'o" To: Andreas Dilger Cc: Ext4 Developers List , Saranya Muruganandam , Wang Shilong Subject: Re: [PATCH RFC 4/5] ext2fs: parallel bitmap loading Message-ID: <20201211223512.GC575698@mit.edu> References: <20201205045856.895342-1-tytso@mit.edu> <20201205045856.895342-5-tytso@mit.edu> <4F169AE8-BFD2-4EE3-8741-7C75B8764583@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F169AE8-BFD2-4EE3-8741-7C75B8764583@dilger.ca> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Dec 10, 2020 at 05:12:09PM -0700, Andreas Dilger wrote: > > @@ -329,12 +369,20 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) > > } > > if (!bitmap_tail_verify((unsigned char *) block_bitmap, > > block_nbytes, fs->blocksize - 1)) > > - tail_flags |= EXT2_FLAG_BBITMAP_TAIL_PROBLEM; > > + *tail_flags |= EXT2_FLAG_BBITMAP_TAIL_PROBLEM; > > } else > > memset(block_bitmap, 0, block_nbytes); > > cnt = block_nbytes << 3; > > +#ifdef HAVE_PTHREAD > > + if (mutex) > > + pthread_mutex_lock(mutex); > > +#endif > > retval = ext2fs_set_block_bitmap_range2(fs->block_map, > > blk_itr, cnt, block_bitmap); > > +#ifdef HAVE_PTHREAD > > + if (mutex) > > + pthread_mutex_unlock(mutex); > > +#endif > > (style) It wouldn't be terrible to have wrappers around these functions > instead of inline #ifdef in the few places they are used, like: > > #ifdef HAVE_PTHREAD > static void unix_pthread_mutex_lock(pthread_mutex_t *mutex) > { > if (mutex) > pthread_mutex_lock(mutex); > } > static void unix_pthread_mutex_unlock(pthread_mutex_t *mutex) > { > if (mutex) > pthread_mutex_unlock(mutex); > } > #else > #define unix_pthread_mutex_lock(mutex) do {} while (0) > #define unix_pthread_mutex_unlock(mutex) do {} while (0) > #endif We'd also need to have a typedef for mutex_t which is either pthreads_mutex_t if pthreads are available, or an int (or some other placeholder type) if it isn't. I had tried to make sure that rw_bitmaps.c will correctly compile with HAVE_PTHREAD and HAVE_PTHREAD_H are undefined. It looks like I didn't quite get it completely working since there's at leasts one function signature where we have an unprotected use of pthread_mutex_t, so that's something we should check before finalizing the patch --- in addition to the unprotected use of pthread_mutex_{lock,unlock} that you pointed out. - Ted