From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f65.google.com ([209.85.160.65]:40704 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754522AbeDBXAI (ORCPT ); Mon, 2 Apr 2018 19:00:08 -0400 Received: by mail-pl0-f65.google.com with SMTP id x4-v6so6152017pln.7 for ; Mon, 02 Apr 2018 16:00:08 -0700 (PDT) Date: Mon, 2 Apr 2018 16:00:06 -0700 From: Omar Sandoval To: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel-team@fb.com, Matthew Wilcox , Andrew Morton , Rasmus Villemoes , Linus Torvalds , stable@vger.kernel.org Subject: Re: [PATCH] bitmap: fix memset optimization on big-endian systems Message-ID: <20180402230006.GB18049@vader> References: <817147544aa3ecc2b78d6cadeab713869d8805e6.1522709616.git.osandov@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <817147544aa3ecc2b78d6cadeab713869d8805e6.1522709616.git.osandov@fb.com> Sender: stable-owner@vger.kernel.org List-ID: On Mon, Apr 02, 2018 at 03:58:31PM -0700, Omar Sandoval wrote: > From: Omar Sandoval > > Commit 2a98dc028f91 introduced an optimization to bitmap_{set,clear}() > which uses memset() when the start and length are constants aligned to a > byte. This is wrong on big-endian systems; our bitmaps are arrays of > unsigned long, so bit n is not at byte n / 8 in memory. This was caught > by the Btrfs selftests, but the bitmap selftests also fail when run on a > big-endian machine. > > We can still use memset if the start and length are aligned to an > unsigned long, so do that on big-endian. The same problem applies to the > memcmp in bitmap_equal(), so fix it there, too. > > Fixes: 2a98dc028f91 ("include/linux/bitmap.h: turn bitmap_set and bitmap_clear into memset when possible") > Fixes: 2c6deb01525a ("bitmap: use memcmp optimisation in more situations") > Cc: stable@kernel.org This should be stable@vger.kernel.org, of course