From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDA2F43B3D1 for ; Thu, 20 Aug 2026 13:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787233221; cv=none; b=T9JY+IAs9CahsFE3EG2ubQsPjxS7G88zFelK9iv08/hYW+LCmWnwpQZGDsSt1KyMKe/+e7aXfeuXjPW+3XkI6b49mqBXiR14BtLV5nvNhtoSFaOXxKZACknkOEhKerZjAK5IAZimmifAMOzTYamAFCSaMpBpdlHeRJaWbNTKeIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787233221; c=relaxed/simple; bh=98qAq68Wg+B3gtocnxXzcqlGrep9cl3PdkVg0ukToAs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=eoIfrWu7jQ56wOIjuPOeqeeh4aIEwbQUcVNH+Ddo4zw6jTOf8W8GGC4BaXsY7m5YuL36bnupt1bi7YRH2qJ5cypMHVudHuI1Ne+Ujn78Hth6xVpncNKWeLkQ3ffL5RYGxXUzhWUqFBwKRD6HP7A580SIT6yVVHOTAflAYaepB20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=qP4Z/An7; arc=none smtp.client-ip=115.124.30.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="qP4Z/An7" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1787233207; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=iBrmwIeNKTKMB+LPg59hkXR8E6mblony+dYzbzlE07M=; b=qP4Z/An7ebqoVD5Z/uvILWzA2D/odg2SlM0291m73/fTad/hMRpu4k0vkVI8mPpGv2R8w5o4zOXGFAxBCWmRJ0GKeMygALdFJXrE+7aQlg6LqzY3PVPT0m37dnp+Ko7onEnxjun7qMSkxdTnn1ffNlrOhdGPG6jL2f3Nw6IoWDs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R941e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0X9Jd8lM_1787233207; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0X9Jd8lM_1787233207 cluster:ay36) by smtp.aliyun-inc.com; Thu, 20 Aug 2026 21:40:07 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] erofs: support SEEK_HOLE/SEEK_DATA in inode_share mode Date: Thu, 20 Aug 2026 21:40:06 +0800 Message-Id: <20260820134006.66208-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When inode_share is enabled, erofs_ishare_fops.llseek falls back to generic_file_llseek, which treats the whole file as data and always returns i_size for SEEK_HOLE, hiding real holes in sparse files. Switch it to erofs_file_llseek instead. For user files f_mapping->host is always the real erofs inode, so SEEK_HOLE/SEEK_DATA resolve the per-file on-disk layout via iomap_seek_hole()/iomap_seek_data(). Reviewed-by: Gao Xiang Signed-off-by: Jingbo Xu --- fs/erofs/data.c | 2 +- fs/erofs/internal.h | 1 + fs/erofs/ishare.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index d2f01245ee79..09d668deb86d 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -509,7 +509,7 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc) #define erofs_file_mmap_prepare generic_file_readonly_mmap_prepare #endif -static loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence) +loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file->f_mapping->host; const struct iomap_ops *ops = &erofs_iomap_ops; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 57bd21859c65..0cd434d939ba 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -411,6 +411,7 @@ void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb, int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev); int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len); +loff_t erofs_file_llseek(struct file *file, loff_t offset, int whence); int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map); void erofs_onlinefolio_init(struct folio *folio); void erofs_onlinefolio_split(struct folio *folio); diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index fa7d4112dec5..4c7be60565cb 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -156,7 +156,7 @@ static int erofs_ishare_fadvise(struct file *file, loff_t offset, const struct file_operations erofs_ishare_fops = { .open = erofs_ishare_file_open, - .llseek = generic_file_llseek, + .llseek = erofs_file_llseek, .read_iter = erofs_ishare_file_read_iter, .mmap = erofs_ishare_mmap, .release = erofs_ishare_file_release, -- 2.19.1.6.gb485710b