Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1187265ybc; Tue, 19 Nov 2019 16:16:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwUOmlerB+EFZXGQ+SXgnbQ5iJYYTxbwSO+ZED9Dh1e6xohfARhyscbf7sdx6VxLmkYcQAI X-Received: by 2002:a17:906:7fcb:: with SMTP id r11mr764454ejs.85.1574209017447; Tue, 19 Nov 2019 16:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574209017; cv=none; d=google.com; s=arc-20160816; b=FYcBGLt3k7Kv89UuHXRZP9XoQ0z5CcU3wyRgngelH5yZB/IOS8GvTKSg6EjAC/k2S+ j5q1lmANyS+gXK2PBAnY7ky1hLhSJPxrVs9noMEXt3h35/HZ8s3dznwNIk93iWEuXRYh RbyMIkunjch+FJLJNF1ar+kwJR3vufnRVR99qP6AtT/oXAr1CAoMxTzTzY7u2R/cvyhU ZIlH716X/i9MQ7HLQFsZEQqsBG1edxYUC7w9NPMkRlS/V3JpuhipQIBqjsafIMQXHgIt v5gzQqwbi7GjlMm8CLNc/kX9fmTh7fgbaFtqofkdxOnbGqsIiWo52Mm1mUTcgi0jFznA p0GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=6bTnI46oqOtD/0PI6VfoSGFeKSdJttZGBNWXLZARbrA=; b=CsGM6u508BHfa2F7cfZbXBTCoG9b/CwQpACyeLZqfeIw8a5R5gtUwn5pCA/J6XUJsH +6Yod7Wu6ZCt8GnfY8SZ4Vg+yvd/mMdqCoIqvR5rU5FkgL6RSyx1lTncwoyt1Fs5bFFx cA7LSbh8blNVbiuTPgJGwf6hDzUubT1rdxy2ibbhuvJE7P0BsSKOmY4jswNhcD65iL6C arS7PyBMlqg2QY6lGHEmNnGNKN1UuGz33Xnd9rtAUcr0m8p/3PLAw+0SKKRtJsXtxgvY uv2fabG3Unwnfqrls1hSsDncZL85ZTS47uTEUNGA03cD1uaoyWuKxGEJng+6naC6MbXO zYlg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=libc.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q30si18218656edb.372.2019.11.19.16.16.31; Tue, 19 Nov 2019 16:16: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=libc.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbfKTAPZ (ORCPT + 99 others); Tue, 19 Nov 2019 19:15:25 -0500 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:50208 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727226AbfKTAPY (ORCPT ); Tue, 19 Nov 2019 19:15:24 -0500 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1iXDeU-0006sP-00; Wed, 20 Nov 2019 00:15:22 +0000 Date: Tue, 19 Nov 2019 19:15:22 -0500 From: Rich Felker To: linux-fsdevel@vger.kernel.org Cc: musl@lists.openwall.com, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org Subject: getdents64 lost direntries with SMB/NFS and buffer size < unknown threshold Message-ID: <20191120001522.GA25139@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An issue was reported today on the Alpine Linux tracker at https://gitlab.alpinelinux.org/alpine/aports/issues/10960 regarding readdir results from SMB/NFS shares with musl libc. After a good deal of analysis, we determined the root cause to be that the second and subsequent calls to getdents64 are dropping/skipping direntries (that have not yet been deleted) when some entries were deleted following the previous call. The issue appears to happen only when the buffer size passed to getdents64 is below some threshold greater than 2k (the size musl uses) but less than 32k (the size glibc uses, with which we were unable to reproduce the issue). My guess at the mechanism of failure is that the kernel has cached some entries which it obtained from the FS server based on whatever its preferred transfer size is, but didn't yet pass them to userspace due to limited buffer space, and then purged the buffer when resuming getdents64 after some entries were deleted for reasons related to the changes made way back in 0c0308066ca5 (NFS: Fix spurious readdir cookie loop messages). If so, any such purge likely needs to be delayed until already-buffered results are read, and there may be related buggy interactions with seeking that need to be examined. The to/cc for this message are just my best guesses. Please cc anyone I missed who should be included when replying, and keep me on cc since I'm not subscribed to any of these lists but the musl one. Rich