From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([198.137.202.133]:43262 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727145AbeIETCP (ORCPT ); Wed, 5 Sep 2018 15:02:15 -0400 Date: Wed, 5 Sep 2018 07:31:47 -0700 From: Matthew Wilcox To: Carlos Maiolino Cc: linux-fsdevel@vger.kernel.org, hch@lst.de, sandeen@redhat.com, david@fromorbit.com Subject: Re: [PATCH 2/2] Use fiemap internal infra-structure to handle FIBMAP Message-ID: <20180905143147.GC3729@bombadil.infradead.org> References: <20180905135748.30098-1-cmaiolino@redhat.com> <20180905135748.30098-3-cmaiolino@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180905135748.30098-3-cmaiolino@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Sep 05, 2018 at 03:57:48PM +0200, Carlos Maiolino wrote: > + if (inode->i_op->fiemap) { > + fextent.fe_logical = 0; > + fextent.fe_physical = 0; > + fieinfo.fi_flags = FIEMAP_KERNEL_FIBMAP; > + fieinfo.fi_extents_max = 1; > + fieinfo.fi_extents_start = (__force struct fiemap_extent __user *) &fextent; > + > + error = inode->i_op->fiemap(inode, &fieinfo, start, 1); You'd have to play games with set_fs() and friends if you want to do this. The fiemap implementation is going to access fi_extents_start with a call to copy_to_user() and for machines with a 4G/4G split, you need that address to be interpreted as kernel space, not user space. See fiemap_fill_next_extent(): struct fiemap_extent __user *dest = fieinfo->fi_extents_start; ... if (copy_to_user(dest, &extent, sizeof(extent))) return -EFAULT;