From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14944 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.kernel,gmane.linux.file-systems,gmane.linux.lib.musl.general,gmane.linux.nfs,gmane.linux.kernel.cifs Subject: getdents64 lost direntries with SMB/NFS and buffer size < unknown threshold Date: Tue, 19 Nov 2019 19:15:22 -0500 Message-ID: <20191120001522.GA25139@brightrain.aerifal.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="50732"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: musl@lists.openwall.com, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org To: linux-fsdevel@vger.kernel.org Original-X-From: linux-kernel-owner@vger.kernel.org Wed Nov 20 01:15:27 2019 Return-path: Envelope-to: glk-linux-kernel-4@m.gmane.org Original-Received: from vger.kernel.org ([209.132.180.67]) by blaine.gmane.org with esmtp (Exim 4.89) (envelope-from ) id 1iXDeY-000D5Q-M9 for glk-linux-kernel-4@m.gmane.org; Wed, 20 Nov 2019 01:15:27 +0100 Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbfKTAPZ (ORCPT ); Tue, 19 Nov 2019 19:15:25 -0500 Original-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 Original-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 Content-Disposition: inline Original-Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xref: news.gmane.org gmane.linux.kernel:3292054 gmane.linux.file-systems:159527 gmane.linux.lib.musl.general:14944 gmane.linux.nfs:89563 gmane.linux.kernel.cifs:15742 Archived-At: 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