From owner-freebsd-fs@freebsd.org Mon Feb 1 15:57:42 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3B455A977B5 for ; Mon, 1 Feb 2016 15:57:42 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E77EF3CB for ; Mon, 1 Feb 2016 15:57:41 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-wm0-x232.google.com with SMTP id p63so77953877wmp.1 for ; Mon, 01 Feb 2016 07:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sippysoft-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=TKiEcyW8IJjvA5A+4lOhu3pEUp15Mjsv84Oykb+OFn4=; b=jNiDsEWbvVf2WHM22KW2BxdOFVs2N7VH9+RlQZvWEH5wB1MACg8TSH4HfwGGsuhDfg xbqRYxikGTlakCIadyQ3U3NOXgkbCLyf84kPqPh1VFgVIJ9NYkgK1FGH/v4pn5L/1pu0 KvOlp0hGDHNtuydLQVjfN6SqSrxGybo5c1slFpiCTKOLoTVr6sevBW5el3W70NJoETqz 642GMLVuar49uCCOzGpoOdheDV8prgodXobrj/s+NmXSTqzYMJ4v3zzGXBupYleCI3Sh CnJUzjudMc1Mrg/3RgTW5zUDcKgUU57BluU7Hmx7hi9iHS35yAJQUjloVJ881E54g8X5 Cgmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:date:message-id:subject:from :to:content-type; bh=TKiEcyW8IJjvA5A+4lOhu3pEUp15Mjsv84Oykb+OFn4=; b=Klre/UkMMBcNmdQMQcQyssvFyNESsx5o3v3zv42E3BDJqJqPIn+o8q6DvzKbWUOOb/ RNBu6LHUiRTj52X4Pecuc3PYgWezKYXeWvDIMCsgucLqczweWs8l8z92XMh8kai9HLfO /P6Gux5jOz8XAqyZXKJUtRoo0SsfrZe6NDOaJ7GQQkpRXoJckpONr+ZAQyl0PlkF4AJy 8YTACdiLqJAIwbWFSiaaisRDAhjeuHOATkS4cgziHU4XENl0egDWeWqBO6GnTsaJRcen 1/vjk85mZWyOAvtkbmspPNCgPjnnpS/NH7ftGOICdI6R7SPsi51wiGZSiVK6A3SUmctu OO4Q== X-Gm-Message-State: AG10YOQzJQEzcq7Ju8EP9I65Uwf73/gb803ZwzC76U1ZXHMohjyUDVlpQCO1lCRuhBiVQgfXJIc+6nBV5k7E6tSE MIME-Version: 1.0 X-Received: by 10.194.192.71 with SMTP id he7mr27543943wjc.82.1454342260257; Mon, 01 Feb 2016 07:57:40 -0800 (PST) Sender: sobomax@sippysoft.com Received: by 10.27.39.195 with HTTP; Mon, 1 Feb 2016 07:57:40 -0800 (PST) Date: Mon, 1 Feb 2016 07:57:40 -0800 X-Google-Sender-Auth: 1jmn6lj3Tgb2W_Aqhi5K4b_XJRQ Message-ID: Subject: Inconsistency between lseek(SEEK_HOLE) and lseek(SEEK_DATA) From: Maxim Sobolev To: freebsd-fs@freebsd.org, Kirk McKusick , kib@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2016 15:57:42 -0000 Hi, I've noticed that lseek() behaved inconsistently with regards to SEEK_HOLE and SEEK_DATA operations. The SEEK_HOLE on a data-only file returns st_size (i.e. EOF + 1), while the SEEK_DATA on a hole-only file returns -1 and sets errno to ENXIO. The latter seems to be a documented way to indicate that the file has no more data sections past this point. My first idea was that somehow most files has a hole attached to its end to fill up the FS block, but that does not seem to be a case. Trying to SEEK_HOLE past the end of any of those data-only files produces an error (i.e. lseek(fd, st_size, SEEK_HOLE) == -1). In short, for some reason I cannot get proper ENXIO from the SEEK_HOLE. What currently returned implies that there is 1-byte hole attached to each file past its EOF and that does not smell right. All tests are done on UFS, fairly recent 11-current. -Max