Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13549207pxu; Sun, 3 Jan 2021 19:48:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkQARuojnS02rWu+sIfiatRsHVcAPgGg92zVThKoAh0aXO2R+emPat3PJzHnntKnKKtnY7 X-Received: by 2002:a17:906:c7d9:: with SMTP id dc25mr640168ejb.138.1609732135462; Sun, 03 Jan 2021 19:48:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609732135; cv=none; d=google.com; s=arc-20160816; b=pIk7nd3W2jhWUopm/vNE2zUs4JbLaPcJJkaZ1u7bTMWi7muHKAMU6z6mg8213STJt2 GWAgRT/Vpn7BhCG5YRWu6bQ1PPeulOTD/iWuBHlQ08Qj7vM2OeNR/Pe00b6/iE98Tl2M nuNPwhxefVgtVOy396jbRXH22D2g9e25V2Uu04W8siyTrvbVdktd1Fo8JxbZgO/SQeqG RG0WdBZMtb+LlsiJ9Z2aQlSARG+D/2TsusUZ9dSSpErt5pUzPE41BKG7tbZPF64vMIMH tL9D+SAwuigLqCmX0fGk/6bi4G/9L+Y+qSLNWeby0HKmFYAvDU0fGgTCKT8nlkbwm/iN Tz5g== 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:dkim-signature; bh=QqpupMZVVb2ckS4eUo7CRnOkNp8jzFCdbETfMfg6E94=; b=yPJHjxg1A8eEtMVSJKTe5VaicwBaSEjPlAPb3FDj2H7jxq318IPhV+mSqUiHCuG9RA xUZ3FFR4UHBiOG27SAn4NhWBInOq8iFxpr0F3EqyoX1Bgnco7S4ihER+lFC3lu7T3uKk NGKEfzI0PctIcbaIUI/UUQSIrcHufBD/ECWwa7+kKFcqVYYqT/pLBOpr0/8RRf9WG7rQ kHyw8kieP70ElAAO4glQy3EqYK4G3yw6SG7lqSd+tFRNbmFXOOe5KSby1e8WzPkPXB9F WoA/3r7s/89vTDTciGGrQOI3TNySdRm5JJk9oL3VgmDrTzTeD34Xpj+4sQHkxpGjSn7j TWaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JCbgQbeT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 e10si31686086edk.554.2021.01.03.19.48.32; Sun, 03 Jan 2021 19:48:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JCbgQbeT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbhADCUG (ORCPT + 99 others); Sun, 3 Jan 2021 21:20:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727740AbhADCUF (ORCPT ); Sun, 3 Jan 2021 21:20:05 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F9D6C061793; Sun, 3 Jan 2021 18:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=QqpupMZVVb2ckS4eUo7CRnOkNp8jzFCdbETfMfg6E94=; b=JCbgQbeTC6kNU+StFdzzSvAEI+ 1TsMn3GaPtp0EINKulyUo3KufXLVJnaA02gNlJY9DrA0pziDzBlysKbI9WWAt6A2MsGqyXLgAkm0p nbI6NJBh4cu8U94JlNLA0XDHy9VsKXO0Q0+0JgxkmxC/sTi3FnZ1ryzTpEdBW+RuHTXZcMCJX64G5 fw9y5IdJ4GV/2F/1ncNW0iRApc53EzIp+q4YR30z7aqlCCjqywI5b7Q4NzxkEwfpS1lfNtXjLccDs hlHDVI3BOSm5qaYTbGGmHkuu9169GlKWjb1V8/P6Gz2bGZm/lp/ovL+tEIJR+D1TUlF6HiuG9ELEl rlFs9r6w==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1kwFSE-000bDU-8v; Mon, 04 Jan 2021 02:19:05 +0000 Date: Mon, 4 Jan 2021 02:18:42 +0000 From: Matthew Wilcox To: Konstantin Komarov Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, pali@kernel.org, dsterba@suse.cz, aaptel@suse.com, rdunlap@infradead.org, joe@perches.com, mark@harmstone.com, nborisov@suse.com, linux-ntfs-dev@lists.sourceforge.net, anton@tuxera.com, dan.carpenter@oracle.com, hch@lst.de, ebiggers@kernel.org, andy.lavr@gmail.com Subject: Re: [PATCH v17 04/10] fs/ntfs3: Add file operations and implementation Message-ID: <20210104021842.GB28414@casper.infradead.org> References: <20201231152401.3162425-1-almaz.alexandrovich@paragon-software.com> <20201231152401.3162425-5-almaz.alexandrovich@paragon-software.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201231152401.3162425-5-almaz.alexandrovich@paragon-software.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 31, 2020 at 06:23:55PM +0300, Konstantin Komarov wrote: > +/* > + * file_operations::iterate_shared > + * > + * Use non sorted enumeration. > + * We have an example of broken volume where sorted enumeration > + * counts each name twice > + */ > +static int ntfs_readdir(struct file *file, struct dir_context *ctx) > +{ > + const struct INDEX_ROOT *root; > + u64 vbo; > + size_t bit; > + loff_t eod; > + int err = 0; > + struct inode *dir = file_inode(file); > + struct ntfs_inode *ni = ntfs_i(dir); > + struct super_block *sb = dir->i_sb; > + struct ntfs_sb_info *sbi = sb->s_fs_info; > + loff_t i_size = i_size_read(dir); > + u32 pos = ctx->pos; > + u8 *name = NULL; > + struct indx_node *node = NULL; > + u8 index_bits = ni->dir.index_bits; > + > + /* name is a buffer of PATH_MAX length */ > + static_assert(NTFS_NAME_LEN * 4 < PATH_MAX); > + > + eod = i_size + sbi->record_size; > + > + if (pos >= eod) > + return 0; > + > + if (!dir_emit_dots(file, ctx)) > + return 0; > + > + /* allocate PATH_MAX bytes */ > + name = __getname(); > + if (!name) > + return -ENOMEM; > + > + ni_lock(ni); What is this lock protecting?