YET ANOTHER resend of the fiemap patches
Subsystems (6)
Theodore Ts'o
maintainerSo the last round of the on-going round-and-round of the FIEMAP patches went to the linux-ext4 mailing list, because of a query there about why these patches had been stalled for so long. This resulted in a private set of e-mails attacking an ext4 developer and putting forward a conspiracy theory that these patches were trying to be snuck in, despite the fact that they have been sent on linux-fsdevel at least 4 times already.
Mark has at this point I believe answered all of Christoph Hellwig's demands, and put forward a request to Andrew Morton to include them in -mm (minus the ext4 patch, since the version he had no longer compiled).
As of this writing, Andrew has not put them into -mm, I suspect because he perceives there is still controversies around these patches, despite the fact that most of the e-mails and time wasted has been over individual bitflags and other really tiny nit-picky details. So I am re-sending these patches out for review on linux-fsdevel. The first three patches are taken from Mark's fiemap branch on the ocfs2 branch. The last patch is an updated ext4 patch from the ext4 patch queue, which is provided so that folks can see that the fiemap patches work just fine on ext4.
Given that filesystem designers seem to love nit-picking tiny details, and I am personally starting to lose patience, if the fiemap patches stalls any further, my plan is to take a page from the XFS playbook and simply take the ext4-fiemap patch and implement an ext4-specific ioctl. If and when the linux-fsdevel community manages come to consensus on the fiemap patches, whether it happens in 2.6.28 or Linux 2.6.87, it will be easy enough to wire the ext4 support to the generic fiemap ioctl.
"It's *just* an ioctl, folks" --- Andreas Dilger
Yours disgustedly,
- Ted
Theodore Ts'o
maintainerPATCH 1/4 vfs: vfs-level fiemap interface
From: Mark Fasheh <[email protected]>
Basic vfs-level fiemap infrastructure, which sets up a new ->fiemap inode operation.
Userspace can get extent information on a file via fiemap ioctl. As input, the fiemap ioctl takes a struct fiemap which includes an array of struct fiemap_extent (fm_extents). Size of the extent array is passed as fm_extent_count and number of extents returned will be written into fm_mapped_extents. Offset and length fields on the fiemap structure (fm_start, fm_length) describe a logical range which will be searched for extents. All extents returned will at least partially contain this range. The actual extent offsets and ranges returned will be unmodified from their offset and range on-disk.
The fiemap ioctl returns '0' on success. On error, -1 is returned and errno is set. If errno is equal to EBADR, then fm_flags will contain those flags which were passed in which the kernel did not understand. On all other errors, the contents of fm_extents is undefined.
As fiemap evolved, there have been many authors of the vfs patch. As far as I can tell, the list includes:
Kalpak Shah <[email protected]>
Andreas Dilger <[email protected]>
Eric Sandeen <[email protected]>
Mark Fasheh <[email protected]>
--- Documentation/filesystems/fiemap.txt | 216 ++++++++++++++++++++++++++++++++++ fs/ioctl.c | 154 ++++++++++++++++++++++++ include/linux/fiemap.h | 62 ++++++++++ include/linux/fs.h | 18 +++ 4 files changed, 450 insertions(+), 0 deletions(-) create mode 100644 Documentation/filesystems/fiemap.txt create mode 100644 include/linux/fiemap.h
Documentation/filesystems/fiemap.txt new file +216 -0
@@ -0,0 +1,216 @@ +============ +Fiemap Ioctl +============ + +The fiemap ioctl is an efficient method for userspace to get file +extent mappings. Instead of block-by-block mapping (such as bmap), fiemap +returns a list of extents. + + +Request Basics +-------------- + +A fiemap request is encoded within struct fiemap: + +struct fiemap { + __u64 fm_start; /* logical offset (inclusive) at + * which to start mapping (in) */ + __u64 fm_length; /* logical length of mapping which + * userspace cares about (in) */ + __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */ + __u32 fm_mapped_extents; /* number of extents that were + * mapped (out) */ + __u32 fm_extent_count; /* size of fm_extents array (in) */ + __u32 fm_reserved; + struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */ +}; + + +fm_start, and fm_length specify the logical range within the file +which the process would like mappings for. Extents returned mirror +those on disk - that is, the logical offset of the 1st returned extent +may start before fm_start, and the range covered by the last returned +extent may end after fm_length. All offsets and lengths are in bytes. + +Certain flags to modify the way in which mappings are looked up can be +set in fm_flags. If the kernel doesn't understand some particular +flags, it will return EBADR and the contents of fm_flags will contain +the set of flags which caused the error. If the kernel is compatible +with all flags passed, the contents of fm_flags will be unmodified. +It is up to userspace to determine whether rejection of a particular +flag is fatal to it's operation. This scheme is intended to allow the +fiemap interface to grow in the future but without losing +compatibility with old software. + +fm_extent_count specifies the number of elements in the fm_extents[] array +that can be used to return extents. If fm_extent_count is zero, then the +fm_extents[] array is ignored (no extents will be returned), and the +fm_mapped_extents count will hold the number of extents needed in +fm_extents[] to hold the file's current mapping. Note that there is +nothing to prevent the file from changing between calls to FIEMAP. + +Currently, there are three flags which can be set in fm_flags: + +* FIEMAP_FLAG_SYNC +If this flag is set, the kernel will sync the file before mapping extents. + +* FIEMAP_FLAG_XATTR +If this flag is set, the extents returned will describe the inodes +extended attribute lookup tree, instead of it's data tree. + + +Extent Mapping +-------------- + +Extent information is returned within the embedded fm_extents array +which userspace must allocate along with the fiemap structure. The +number of elements in the fiemap_extents[] array should be passed via +fm_extent_count. The number of extents mapped by kernel will be +returned via fm_mapped_extents. If the number of fiemap_extents +allocated is less than would be required to map the requested range, +the maximum number of extents that can be mapped in the fm_extent[] +array will be returned and fm_mapped_extents will be equal to +fm_extent_count. In that case, the last extent in the array will not +complete the requested range and will not have the FIEMAP_EXTENT_LAST +flag set (see the next section on extent flags). + +Each extent is described by a single fiemap_extent structure as +returned in fm_extents. + +struct fiemap_extent { + __u64 fe_logical; /* logical offset in bytes for the start of + * the extent */ + __u64 fe_physical; /* physical offset in bytes for the start + * of the extent */ + __u64 fe_length; /* length in bytes for the extent */ + __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ + __u32 fe_reserved; +}; + +All offsets and lengths are in bytes and mirror those on disk. It is valid +for an extents logical offset to start before the request or it's logical +length to extend past the request. Unless FIEMAP_EXTENT_NOT_ALIGNED is +returned, fe_logical, fe_physical, and fe_length will be aligned to the +block size of the file system. With the exception of extents flagged as +FIEMAP_EXTENT_MERGED, adjacent extents will not be merged. + +The fe_flags field contains flags which describe the extent returned. +A special flag, FIEMAP_EXTENT_LAST is always set on the last extent in +the file so that the process making fiemap calls can determine when no +more extents are available, without having to call the ioctl again. + +Some flags are intentionally vague and will always be set in the +presence of other more specific flags. This way a program looking for +a general property does not have to know all existing and future flags +which imply that property. + +For example, if FIEMAP_EXTENT_DATA_INLINE or FIEMAP_EXTENT_DATA_TAIL +are set, FIEMAP_EXTENT_NOT_ALIGNED will also be set. A program looking +for inline or tail-packed data can key on the specific flag. Software +which simply cares not to try operating on non-aligned extents +however, can just key on FIEMAP_EXTENT_NOT_ALIGNED, and not have to +worry about all present and future flags which might imply unaligned +data. Note that the opposite is not true - it would be valid for +FIEMAP_EXTENT_NOT_ALIGNED to appear alone. + +* FIEMAP_EXTENT_LAST +This is the last extent in the file. A mapping attempt past this +extent will return nothing. + +* FIEMAP_EXTENT_UNKNOWN +The location of this extent is currently unknown. This may indicate +the data is stored on an inaccessible volume or that no storage has +been allocated for the file yet. + +* FIEMAP_EXTENT_DELALLOC + - This will also set FIEMAP_EXTENT_UNKNOWN. +Delayed allocation - while there is data for this extent, it's +physical location has not been allocated yet. + +* FIEMAP_EXTENT_NO_BYPASS +Direct access to the data in this extent is illegal or will have +undefined results. + +* FIEMAP_EXTENT_DATA_ENCRYPTED + - This will also set FIEMAP_EXTENT_NO_BYPASS +The data in this extent has been encrypted by the file system. + +* FIEMAP_EXTENT_NOT_ALIGNED +Extent offsets and length are not guaranteed to be block aligned. + +* FIEMAP_EXTENT_DATA_INLINE + This will also set FIEMAP_EXTENT_NOT_ALIGNED +Data is located within a meta data block. + +* FIEMAP_EXTENT_DATA_TAIL + This will also set FIEMAP_EXTENT_NOT_ALIGNED +Data is packed into a block with data from other files. + +* FIEMAP_EXTENT_UNWRITTEN +Unwritten extent - the extent is allocated but it's data has not been +initialized. This indicates the extent's data will be all zero if read +through the filesystem but the contents are undefined if read directly from +the device. + +* FIEMAP_EXTENT_MERGED +This will be set when a file does not support extents, i.e., it uses a block +based addressing scheme. Since returning an extent for each block back to +userspace would be highly inefficient, the kernel will try to merge most +adjacent blocks into 'extents'. + + +VFS -> File System Implementation +--------------------------------- + +File systems wishing to support fiemap must implement a ->fiemap callback on +their inode_operations structure. The fs ->fiemap call is responsible for +defining it's set of supported fiemap flags, and calling a helper function on +each discovered extent: + +struct inode_operations { + ... + + int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, + u64 len); + +->fiemap is passed struct fiemap_extent_info which describes the +fiemap request: + +struct fiemap_extent_info { + unsigned int fi_flags; /* Flags as passed from user */ + unsigned int fi_extents_mapped; /* Number of mapped extents */ + unsigned int fi_extents_max; /* Size of fiemap_extent array */ + struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */ +}; + +It is intended that the file system should not need to access any of this +structure directly. + + +Flag checking should be done at the beginning of the ->fiemap callback via the +fiemap_check_flags() helper: + +int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); + +The struct fieinfo should be passed in as recieved from ioctl_fiemap(). The +set of fiemap flags which the fs understands should be passed via fs_flags. If +fiemap_check_flags finds invalid user flags, it will place the bad values in +fieinfo->fi_flags and return -EBADR. If the file system gets -EBADR, from +fiemap_check_flags(), it should immediately exit, returning that error back to +ioctl_fiemap(). + + +For each extent in the request range, the file system should call +the helper function, fiemap_fill_next_extent(): + +int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, + u64 phys, u64 len, u32 flags, u32 dev); + +fiemap_fill_next_extent() will use the passed values to populate the +next free extent in the fm_extents array. 'General' extent flags will +automatically be set from specific flags on behalf of the calling file +system so that the userspace API is not broken. + +fiemap_fill_next_extent() returns 0 on success, and 1 when the +user-supplied fm_extents array is full. If an error is encountered +while copying the extent to user memory, -EFAULT will be returned.
fs/ioctl.c +154 -0
172 lines not on this page · raw message
include/linux/fiemap.h new file +62 -0
62 lines not on this page · raw message
include/linux/fs.h +18 -0
@@ -231,6 +231,7 @@ extern int dir_notify_enable;#define FS_IOC_SETFLAGS _IOW('f', 2, long)#define FS_IOC_GETVERSION _IOR('v', 1, long)#define FS_IOC_SETVERSION _IOW('v', 2, long) +#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)#define FS_IOC32_GETFLAGS _IOR('f', 1, int)#define FS_IOC32_SETFLAGS _IOW('f', 2, int)#define FS_IOC32_GETVERSION _IOR('v', 1, int)
@@ -291,6 +292,7 @@ extern int dir_notify_enable;#include <linux/mutex.h> #include <linux/capability.h> #include <linux/semaphore.h> +#include <linux/fiemap.h> #include <asm/atomic.h> #include <asm/byteorder.h>
@@ -1179,6 +1181,20 @@ extern void dentry_unhash(struct dentry *dentry);extern int file_permission (struct file *,int );/* +* VFS FS_IOC_FIEMAP helper definitions. +*/ +struct fiemap_extent_info { +unsigned int fi_flags;/* Flags as passed from user */ +unsigned int fi_extents_mapped;/* Number of mapped extents */ +unsigned int fi_extents_max;/* Size of fiemap_extent array */ +struct fiemap_extent *fi_extents_start;/* Start of fiemap_extent +* array */ +}; +int fiemap_fill_next_extent (struct fiemap_extent_info *info,u64 logical, +u64 phys,u64 len,u32 flags); +int fiemap_check_flags (struct fiemap_extent_info *fieinfo,u32 fs_flags); + +/* * File types * * NOTE! These match bits 12..15 of stat.st_mode
@@ -1287,6 +1303,8 @@ struct inode_operations {void (*truncate_range)(struct inode *,loff_t ,loff_t );long (*fallocate)(struct inode *inode,int mode,loff_t offset,loff_t len); +int (*fiemap)(struct inode *,struct fiemap_extent_info *,u64 start, +u64 len); };struct seq_file ;
Signature · 1 line
1.5.6.1.205.ge2c7.dirty
Theodore Ts'o
maintainerPATCH 2/4 ocfs2: fiemap support
From: Mark Fasheh <[email protected]>
Plug ocfs2 into ->fiemap. Some portions of ocfs2_get_clusters() had to be refactored so that the extent cache can be skipped in favor of going directly to the on-disk records. This makes it easier for us to determine which extent is the last one in the btree. Also, I'm not sure we want to be caching fiemap lookups anyway as they're not directly related to data read/write.
--- fs/ocfs2/alloc.c | 9 -- fs/ocfs2/alloc.h | 9 ++ fs/ocfs2/extent_map.c | 346 +++++++++++++++++++++++++++++++++++++++++-------- fs/ocfs2/extent_map.h | 3 + fs/ocfs2/file.c | 1 + 5 files changed, 306 insertions(+), 62 deletions(-)
fs/ocfs2/alloc.c +0 -9
@@ -990,15 +990,6 @@ out: }/* -* This is only valid for leaf nodes, which are the only ones that can -* have empty extents anyway. -*/ -static inline int ocfs2_is_empty_extent (struct ocfs2_extent_rec *rec) -{ -return !rec->e_leaf_clusters; -} - -/* * This function will discard the rightmost extent record. */ static void ocfs2_shift_records_right (struct ocfs2_extent_list *el)
fs/ocfs2/alloc.h +9 -0
@@ -146,4 +146,13 @@ static inline unsigned int ocfs2_rec_clusters(struct ocfs2_extent_list *el, return le16_to_cpu(rec->e_leaf_clusters); } +/* +* This is only valid for leaf nodes, which are the only ones that can +* have empty extents anyway. +*/ +static inline int ocfs2_is_empty_extent (struct ocfs2_extent_rec *rec) +{ +return !rec->e_leaf_clusters; +} +#endif /* OCFS2_ALLOC_H */
fs/ocfs2/extent_map.c +293 -53
409 lines not on this page · raw message
fs/ocfs2/extent_map.h +3 -0
@@ -50,4 +50,7 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster,int ocfs2_extent_map_get_blocks (struct inode *inode,u64 v_blkno,u64 *p_blkno,u64 *ret_count,unsigned int *extent_flags); +int ocfs2_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo, +u64 map_start,u64 map_len); +#endif /* _EXTENT_MAP_H */
fs/ocfs2/file.c +1 -0
@@ -2228,6 +2228,7 @@ const struct inode_operations ocfs2_file_iops = { .getattr = ocfs2_getattr, .permission = ocfs2_permission, .fallocate = ocfs2_fallocate, + .fiemap = ocfs2_fiemap, };const struct inode_operations ocfs2_special_file_iops = {
Signature · 1 line
1.5.6.1.205.ge2c7.dirty
Theodore Ts'o
maintainerPATCH 3/4 generic block based fiemap implementation
From: Josef Bacik <[email protected]>
Any block based fs (this patch includes ext3) just has to declare its own fiemap() function and then call this generic function with its own get_block_t. This works well for block based filesystems that will map multiple contiguous blocks at one time, but will work for filesystems that only map one block at a time, you will just end up with an "extent" for each block. One gotcha is this will not play nicely where there is hole+data after the EOF. This function will assume its hit the end of the data as soon as it hits a hole after the EOF, so if there is any data past that it will not pick that up. AFAIK no block based fs does this anyway, but its in the comments of the function anyway just in case.
--- fs/ext2/ext2.h | 2 + fs/ext2/file.c | 1 + fs/ext2/inode.c | 8 +++ fs/ext3/file.c | 1 + fs/ext3/inode.c | 8 +++ fs/ioctl.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/ext3_fs.h | 2 + include/linux/fs.h | 3 + 8 files changed, 143 insertions(+), 0 deletions(-)
fs/ext2/ext2.h +2 -0
@@ -133,6 +133,8 @@ extern void ext2_truncate (struct inode *);extern int ext2_setattr (struct dentry *,struct iattr *);extern void ext2_set_inode_flags (struct inode *inode);extern void ext2_get_inode_flags (struct ext2_inode_info *); +extern int ext2_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo, +u64 start,u64 len);int __ext2_write_begin (struct file *file,struct address_space *mapping,loff_t pos,unsigned len,unsigned flags,struct page **pagep,void **fsdata);
fs/ext2/file.c +1 -0
@@ -86,4 +86,5 @@ const struct inode_operations ext2_file_inode_operations = {#endif .setattr = ext2_setattr, .permission = ext2_permission, + .fiemap = ext2_fiemap, };
fs/ext2/inode.c +8 -0
@@ -31,6 +31,7 @@#include <linux/writeback.h> #include <linux/buffer_head.h> #include <linux/mpage.h> +#include <linux/fiemap.h> #include "ext2.h" #include "acl.h" #include "xip.h"
@@ -704,6 +705,13 @@ int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_ } +int ext2_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo, +u64 start,u64 len) +{ +return generic_block_fiemap (inode, fieinfo, start, len, + ext2_get_block); +} +static int ext2_writepage (struct page *page,struct writeback_control *wbc) {return block_write_full_page (page, ext2_get_block, wbc);
fs/ext3/file.c +1 -0
@@ -134,5 +134,6 @@ const struct inode_operations ext3_file_inode_operations = { .removexattr = generic_removexattr, #endif .permission = ext3_permission, + .fiemap = ext3_fiemap, };
fs/ext3/inode.c +8 -0
@@ -36,6 +36,7 @@#include <linux/mpage.h> #include <linux/uio.h> #include <linux/bio.h> +#include <linux/fiemap.h> #include "xattr.h" #include "acl.h"
@@ -981,6 +982,13 @@ out:return ret; } +int ext3_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo, +u64 start,u64 len) +{ +return generic_block_fiemap (inode, fieinfo, start, len, + ext3_get_block); +} +/* * `handle' can be NULL if create is zero */
fs/ioctl.c +118 -0
130 lines not on this page · raw message
include/linux/ext3_fs.h +2 -0
@@ -837,6 +837,8 @@ extern void ext3_truncate (struct inode *);extern void ext3_set_inode_flags (struct inode *);extern void ext3_get_inode_flags (struct ext3_inode_info *);extern void ext3_set_aops (struct inode *inode); +extern int ext3_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo, +u64 start,u64 len);/* ioctl.c */ extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
include/linux/fs.h +3 -0
@@ -1998,6 +1998,9 @@ extern int vfs_fstat(unsigned int, struct kstat *);extern int do_vfs_ioctl (struct file *filp,unsigned int fd,unsigned int cmd,unsigned long arg); +extern int generic_block_fiemap (struct inode *inode, +struct fiemap_extent_info *fieinfo,u64 start, +u64 len,get_block_t *get_block);extern void get_filesystem (struct file_system_type *fs);extern void put_filesystem (struct file_system_type *fs);
Signature · 1 line
1.5.6.1.205.ge2c7.dirty
Theodore Ts'o
maintainerPATCH 4/4 Hook ext4 to the vfs fiemap interface.
From: Eric Sandeen <[email protected]>
ext4_ext_walk_space() was reinstated to be used for iterating over file extents with a callback; it is used by the ext4 fiemap implementation.
--- fs/ext4/ext4.h | 2 + fs/ext4/ext4_extents.h | 15 +++ fs/ext4/extents.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/file.c | 4 + 4 files changed, 269 insertions(+), 0 deletions(-)
fs/ext4/ext4.h +2 -0
@@ -1127,6 +1127,8 @@ struct buffer_head *ext4_getblk(handle_t *, struct inode *, ext4_lblk_t, int, int *);struct buffer_head *ext4_bread (handle_t *,struct inode *,ext4_lblk_t ,int ,int *); +int ext4_get_block (struct inode *inode,sector_t iblock, +struct buffer_head *bh_result,int create); int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, ext4_lblk_t iblock, unsigned long maxblocks, struct buffer_head *bh_result,
fs/ext4/ext4_extents.h +15 -0
@@ -124,6 +124,19 @@ struct ext4_ext_path {#define EXT4_EXT_CACHE_GAP 1#define EXT4_EXT_CACHE_EXTENT 2 +/* +* to be called by ext4_ext_walk_space() +* negative retcode - error +* positive retcode - signal for ext4_ext_walk_space(), see below +* callback must return valid extent (passed or newly created) +*/ +typedef int (*ext_prepare_callback )(struct inode *,struct ext4_ext_path *, +struct ext4_ext_cache *, +struct ext4_extent *,void *); + +#define EXT_CONTINUE 0 +#define EXT_BREAK 1 +#define EXT_REPEAT 2#define EXT_MAX_BLOCK 0xffffffff
@@ -224,6 +237,8 @@ extern int ext4_ext_try_to_merge(struct inode *inode, struct ext4_extent *);extern unsigned int ext4_ext_check_overlap (struct inode *,struct ext4_extent *,struct ext4_ext_path *);extern int ext4_ext_insert_extent (handle_t *,struct inode *,struct ext4_ext_path *,struct ext4_extent *); +extern int ext4_ext_walk_space (struct inode *,ext4_lblk_t ,ext4_lblk_t , +ext_prepare_callback ,void *);extern struct ext4_ext_path *ext4_ext_find_extent (struct inode *,ext4_lblk_t ,struct ext4_ext_path *); extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
fs/ext4/extents.c +248 -0
263 lines not on this page · raw message
fs/ext4/file.c +4 -0
@@ -140,6 +140,9 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)return 0 ; } +extern int ext4_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo, +__u64 start,__u64 len); +const struct file_operations ext4_file_operations = { .llseek = generic_file_llseek, .read = do_sync_read,
@@ -170,5 +173,6 @@ const struct inode_operations ext4_file_inode_operations = {#endif .permission = ext4_permission, .fallocate = ext4_fallocate, + .fiemap = ext4_fiemap, };
Signature · 1 line
1.5.6.1.205.ge2c7.dirty
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Theodore Ts'oHi,
Just a quick question (not a criticism of the patches in any way):
Is there a specific reason that the flag FIEMAP_EXTENT_DATA_ENCRYPTED exists? I am only asking because there isn't a FIEMAP_EXTENT_DATA_COMPRESSED flag yet the effect on the data is the same. I suppose one could argue that compression is a form of encryption (as one cannot read the data on disk without decompressing it) and thus for compressed files I can just set FIEMAP_EXTENT_DATA_ENCRYPTED, too?
Best regards,
Anton
Signature · 3 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer, http://www.linux-ntfs.org/
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 11 lines · Anton Altaparmakov
Hi,
Just a quick question (not a criticism of the patches in any way):
Is there a specific reason that the flag
FIEMAP_EXTENT_DATA_ENCRYPTEDexists? I am only asking because there isn't aFIEMAP_EXTENT_DATA_COMPRESSEDflag yet the effect on the data is the same. I suppose one could argue that compression is a form of encryption (as one cannot read the data on disk without decompressing it) and thus for compressed files I can just setFIEMAP_EXTENT_DATA_ENCRYPTED, too?
You could, but actually, the interface isn't really set up well to deal with compressed files. In order to deal with compressed data you really would need two fields in struct fiemap_extent:fe_length_physical, fe_length_logical, like this:
struct fiemap_extent {
__u64 fe_logical; /* logical offset in bytes for the start of
* the extent from the beginning of the file */
__u64 fe_physical; /* physical offset in bytes for the start
* of the extent from the beginning of the disk */
__u64 fe_length; /* length in bytes for this extent */
__u64 fe_length_physical; /* length in bytes for this extent as
* encoded/compressed on disk */
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
__u32 fe_reserved;
};
Part of the problem/frustration as we go around and round fs-devel is that some people would request new features to support new filesystems, and other people have been rejecting new features because it makes the interface more complicated.
In fact, the previous version of the patch had a flag for compression, but Cristoph Hellwig objected because he claimed there were no users for it.
I don't care how this interface ends up, at least as far as this point is concerned, but it's really annoying when some people want to add features, and other people are objecting and trying to remove features, and months and months and months go by while the patch languishes while people play tug of war on the d*mned thing.
Probably the best thing to do is to add a much larger number of reserved fields, of size __u32 and __u64, appropriately aligned, and then when someone adds a compressed filesystem, we can add the structure definition without changing the size of the structure. Otherwise, the thou-shalt-not-anticipate-the-needs-of-any-future- users-of-the-interface nazi's will strike again, and more months will go by with absolutely no progress....
- Ted
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 3 lines · Theodore Tso
Otherwise, the thou-shalt-not-anticipate-the-needs-of-any-future- users-of-the-interface nazi's will strike again, and more months will go by with absolutely no progress....
Ted, I appreciate you're feeling frustration, but there's no call for this kind of language. Please moderate your tone.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Theodore TsoHi,
Quoted 16 lines · Theodore Tso
Quoted 9 lines · Anton Altaparmakov
Just a quick question (not a criticism of the patches in any way):
Is there a specific reason that the flag
FIEMAP_EXTENT_DATA_ENCRYPTEDexists? I am only asking because there isn't aFIEMAP_EXTENT_DATA_COMPRESSEDflag yet the effect on the data is the same. I suppose one could argue that compression is a form of encryption (as one cannot read the data on disk without decompressing it) and thus for compressed files I can just setFIEMAP_EXTENT_DATA_ENCRYPTED, too?You could, but actually, the interface isn't really set up well to deal with compressed files. In order to deal with compressed data you really would need two fields in struct
fiemap_extent:fe_length_physical,fe_length_logical, like this:
Quoted 11 lines
struct
fiemap_extent{
__u64fe_logical; /* logical offset in bytes for the start of
* the extent from the beginning of the file */
__u64fe_physical; /* physical offset in bytes for the start
* of the extent from the beginning of the disk */
__u64fe_length; /* length in bytes for this extent */
__u64fe_length_physical; /* length in bytes for this extent as
* encoded/compressed on disk */
__u32fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
__u32fe_reserved;
};
Yes, that could make sense for compressed files although for NTFS at least it does not matter because the logical regions which do not exist on disk (due to compression having made the corresponding physical regions smaller by at least one block) are present in the extent list as sparse extents, so the extents for a compressed file could look like this for example (lengths are in blocks):
logical ofs physical ofs length
0 X 14
14 SPARSE 2
16 Y 4
20 SPARSE 12
32 Z 9
41 SPARSE 7
... ... ...
As you may have noticed from the above example in NTFS each block of 16 blocks is compressed independently, hence the sparse extents interspersed with the compressed extents to bring the logical offset in line with the physical offset.
Quoted 8 lines
Part of the problem/frustration as we go around and round fs-devel is that some people would request new features to support new filesystems, and other people have been rejecting new features because it makes the interface more complicated.
In fact, the previous version of the patch had a flag for compression, but Cristoph Hellwig objected because he claimed there were no users for it.
He is plain wrong then! NTFS supports compressed files and always has done! We only support them read-only at present but that does not matter for the purposes of FIEMAP. And in any case one day we will have write support for compressed files, too...
Quoted 6 lines
I don't care how this interface ends up, at least as far as this point is concerned, but it's really annoying when some people want to add features, and other people are objecting and trying to remove features, and months and months and months go by while the patch languishes while people play tug of war on the d*mned thing.
Quoted 7 lines
Probably the best thing to do is to add a much larger number of reserved fields, of size
__u32and__u64, appropriately aligned, and then when someone adds a compressed filesystem, we can add the structure definition without changing the size of the structure. Otherwise, the thou-shalt-not-anticipate-the-needs-of-any-future- users-of-the-interface nazi's will strike again, and more months will go by with absolutely no progress....
We already have two file systems in the mainline kernel tree that support transparent compression/decompression: ntfs and zisofs so there is no "future" anywhere in sight... (-;
Best regards,
Anton
Signature · 3 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer, http://www.linux-ntfs.org/
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Matthew WilcoxQuoted 7 lines · Matthew Wilcox
Quoted 3 lines · Theodore Tso
Otherwise, the thou-shalt-not-anticipate-the-needs-of-any-future- users-of-the-interface nazi's will strike again, and more months will go by with absolutely no progress....
Ted, I appreciate you're feeling frustration, but there's no call for this kind of language. Please moderate your tone.
Well, being polite and us trying to be constructive hasn't gotten us anywhere, except getting (completely groundless) accusations that one of the ext4 developers was trying to "sneak this in" for the benefit of his company --- and months and months and months of time wasted.
I really am beginning to wish that I had ignored Cristoph's whinging and just pushed an ext4-specific ioctl to Linus, instead of trying to develop a filesystem-generic interface. It's just an ioctl. Let's get this done, and move on. If we need to allocate another ioctl, we can do so. Heck, we have five or six different stat interfaces...
I have no problem adding support so we can support filesystems with compressed extents. What I don't want to have happen is one patch version where we add a feature, and then get another complaint from someone else demanding that we remove that self-same feature from the interface, repeating, ad infinitum. We shouldn't tolerate this kind of sh*t.
- Ted
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Theodore Ts'oDocumentation/filesystems/fiemap.txt line 132
Quoted 3 lines · Theodore Ts'o
Documentation/filesystems/fiemap.txt new file +3
-0+* FIEMAP_EXTENT_NO_BYPASS +Direct access to the data in this extent is illegal or will have +undefined results.
This one is sitll misnamed and for sure utterly misdocumented. Direct access to the data is always illegal and has undefined results, and programs that do it anyway (e.g. grub) are in really deep trouble.
I'm also not sure what happened to my request a few rounds ago to Cc Michael Kerrisk on the thread. He's been writing manpages for all important kernel interfaces, and his review resulting from that has been extremly useful.
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Theodore TsoQuoted 8 lines · Theodore Tso
Part of the problem/frustration as we go around and round fs-devel is that some people would request new features to support new filesystems, and other people have been rejecting new features because it makes the interface more complicated.
In fact, the previous version of the patch had a flag for compression, but Cristoph Hellwig objected because he claimed there were no users for it.
Let's make it clear, I've said to not add it unless we have users. And What Anton brought up is exactly the reason for that - to support encrypted extents we actually need more information in the structure. That's why we need to have this broad and sometimes a little slow discussion on fsdevel instead of just rushing in some flag for future use that won't make any sense in the end.
(and btw, it's Christoph)
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Anton AltaparmakovQuoted 8 lines · Anton Altaparmakov
Quoted 3 lines
In fact, the previous version of the patch had a flag for compression, but Cristoph Hellwig objected because he claimed there were no users for it.
He is plain wrong then! NTFS supports compressed files and always has done! We only support them read-only at present but that does not matter for the purposes of FIEMAP. And in any case one day we will have write support for compressed files, too...
Note that I didn't object it because there are not user, this is just Ted making up BS because he's frustrated. I said don't add it until we actually have users so we know their requirements. The nice part about this interface is that there is no problem adding more flags once we need them, if it's just flags, and if we need mor information than just the flags we're better of discussing these bits beforehand.
Quoted 3 lines
We already have two file systems in the mainline kernel tree that support transparent compression/decompression: ntfs and zisofs so there is no "future" anywhere in sight... (-;
or cramfs. But no one involved with this patch srries bothered actually looking into the requirements.
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Christoph HellwigQuoted 6 lines · Christoph Hellwig
Let's make it clear, I've said to not add it unless we have users. And What Anton brought up is exactly the reason for that - to support encrypted extents we actually need more information in the structure. That's why we need to have this broad and sometimes a little slow discussion on fsdevel instead of just rushing in some flag for future use that won't make any sense in the end.
You're incorrect here. Encrypted extents does not require any additional information in the structure. Compressed extents are a bit more useful if we allow the the filesystem to return the amount of space used on the storage device, but as Anton has pointed out, it's not strictly required for ntfs (although it would be more useful for cramfs). But that being said, the fundamental question here is whether we should try to plan for future users of the data structure, and reserve space now for the, or not. Your approach of saying Nein! Nein! Nein! for every single feature where we don't have implementation pretty much guarantees that we will need to expand the structure later to make room for these extra fields, and then we'll need to define a new ioctl and have similar complexity to the stat system call to support multiple userspace interfaces. If we try to anticipate new users in advance, then there is at least a *chance* we'll get it right up front.
The big problem here is that if we try for a generic interface, we *will* end up stalling for every as some people ask for new features, and other people (like you) push back on it. And in the mean time, we make no progress.
I'd like to break through the logjam, *somehow*. I can see three possible paths:
* We reserve space for likely features that could likely be used by real life filesystems that exist today.
* We don't, and accept the fact that later on we will need to revise the interface, with the resulting hair that this will mean to the kernel.
* I push an ext4-specific ioctl to Linus.
I don't particularly care *which* one we choose, but I'd like for us to make a choice, and then move forward, instead of spinning endlessly.
And no, I haven't made anything up. I'm leaving names out because the accusation was really out of line, and really unfair, so I want to spare the embarassment of the accuser and the accused, but ask Andrew Morton for confirmation if you want. This has gotten beyond ridiculous, and I'd really like us to make a decision, and move *on*.
- Ted
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Christoph HellwigQuoted 8 lines · Christoph Hellwig
Documentation/filesystems/fiemap.txt line 132
Quoted 3 lines · Theodore Ts'o
Documentation/filesystems/fiemap.txt new file +3
-0+* FIEMAP_EXTENT_NO_BYPASS +Direct access to the data in this extent is illegal or will have +undefined results.This one is sitll misnamed and for sure utterly misdocumented. Direct access to the data is always illegal and has undefined results, and programs that do it anyway (e.g. grub) are in really deep trouble.
Programs like Grub *have* to. And in the case of a boot-loader, Lilo and Grub have been able to do so safely for over 15 years. This is basically a generic flag that indicates that they can't, but it reflects the reality that for many filesystems, they *can*. The main legal use is LILO and/or Grub, in fact. One could argue that programs that try accessing data blocks directly while the filesystem is mounted are doomed, but boot loaders do so while the filesystem are unmounted.
The name isn't particularly important, but what it indicates is very clearly useful.
- Ted
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 11 lines · Theodore Tso
Quoted 8 lines · Christoph Hellwig
Documentation/filesystems/fiemap.txt line 132
Quoted 3 lines · Theodore Ts'o
Documentation/filesystems/fiemap.txt new file +3
-0+* FIEMAP_EXTENT_NO_BYPASS +Direct access to the data in this extent is illegal or will have +undefined results.This one is sitll misnamed and for sure utterly misdocumented. Direct access to the data is always illegal and has undefined results, and programs that do it anyway (e.g. grub) are in really deep trouble.
Programs like Grub *have* to.
Depends on which grub you mean. Grub that boot loader has a filesystem driver and accesses it, that's fine. /usr/sbin/grub, the installation program doesn't have to. In fact the only reason why it does is to "verify" that blocks are in place. This breaks down depending on the phase of the moon, but especially badly on filesystems using a different address space than the block device one.
Quoted 2 lines
And in the case of a boot-loader, Lilo
and Grub have been able to do so safely for over 15 years.
I think your arguing 100% profs my point that the flag name and description are utterly confusing. What lilo does is load a kernel from an offset into the partition. This is obviously fine, and a perfect use case for an extent map / block map interface. I think (but not one could clarify to me) that this is the primary use case of the no bypass flag, which is supposed to tell lilo that this extent is not actually a real block but some sort of meshup and lilo should return an error that it gets. But this flag is totally unrelated to beeing able to bypass the filesystem driver when running the kernel which is always bogus, and has caused endless amounts of trouble with the only widespread tool that does it (/usr/sbin/grub).
Quoted 2 lines
The name isn't particularly important, but what it indicates is very clearly useful.
Sometimes I really wish people would read email before replying to them. I did not say anywhere that this flag (at least for the use case I think it is which no one even bothered to document) is good, but the name and description are utterly wrong, and misleading.
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 4 lines · Christoph Hellwig
Sometimes I really wish people would read email before replying to them. I did not say anywhere that this flag (at least for the use case I think it is which no one even bothered to document) is good, but the name and description are utterly wrong, and misleading.
Want to pick a name, then?
- Ted
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 7 lines · Theodore Tso
Quoted 4 lines · Christoph Hellwig
Sometimes I really wish people would read email before replying to them. I did not say anywhere that this flag (at least for the use case I think it is which no one even bothered to document) is good, but the name and description are utterly wrong, and misleading.
Want to pick a name, then?
Again, I'd love it when people would read my mails :( Can we please first agree on what the flag is actually supposed to mean? I made one guess in this mail, but I'm not sure if that's even what Andreas intended. And of course the description for it is even more important than the name.
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Theodore TsoQuoted 8 lines · Theodore Tso
Quoted 6 lines · Christoph Hellwig
Let's make it clear, I've said to not add it unless we have users. And What Anton brought up is exactly the reason for that - to support encrypted extents we actually need more information in the structure. That's why we need to have this broad and sometimes a little slow discussion on fsdevel instead of just rushing in some flag for future use that won't make any sense in the end.
Quoted 4 lines
You're incorrect here. Encrypted extents does not require any additional information in the structure. Compressed extents are a bit more useful if we allow the the filesystem to return the amount of space used on the storage device,
Sorry, should have written compressed and not encrypted above.
Quoted 10 lines
cramfs). But that being said, the fundamental question here is whether we should try to plan for future users of the data structure, and reserve space now for the, or not. Your approach of saying Nein! Nein! Nein! for every single feature where we don't have implementation pretty much guarantees that we will need to expand the structure later to make room for these extra fields, and then we'll need to define a new ioctl and have similar complexity to the stat system call to support multiple userspace interfaces. If we try to anticipate new users in advance, then there is at least a *chance* we'll get it right up front.
I agree to you (or someone elses - don't remember anymore) suggestion to put in more padding so we can add fields later. I strongly disagree putting in features now that we neither have a user, nor a usecase or testcase for.
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 4 lines · Christoph Hellwig
I agree to you (or someone elses - don't remember anymore) suggestion to put in more padding so we can add fields later. I strongly disagree putting in features now that we neither have a user, nor a usecase or testcase for.
So, how about another 64 bits of padding in struct fiemap_extent? That could help cover future uses like compression, which might require another 64 bit offset field - we only have 32 bits of reserved space there right now.
--Mark
--
Mark Fasheh
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
Again, I'd love it when people would read my mails :( Can we please first agree on what the flag is actually supposed to mean? I made one guess in this mail, but I'm not sure if that's even what Andreas intended. And of course the description for it is even more important than the name.
The intent of this flag was a "catch-all" to indicate it isn't safe to try and read this block from disk, either because it is encrypted, compressed, on a remote system (HSM or over a network), or maybe not even written to disk yet (delalloc).
In some cases (e.g. dump on a snapshot, or boot with LILO) it IS ok to read directly from a block device underneath the filesystem, but that would completely fail for the above cases.
Note that the NO_BYPASS (formerly NO_DIRECT) flag is meant to be used in conjunction with other flags that specify more clearly the reason that this block is not directly accessible. Having a "generic" flag cover these different flag allows simple applications to know whether the block is readable or not, without having to understand each flag itself, and allows the flags to be expanded in the future (e.g. HSM or whatever that doesn't get included right away).
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Mark FashehQuoted 9 lines · Mark Fasheh
Quoted 4 lines · Christoph Hellwig
I agree to you (or someone elses - don't remember anymore) suggestion to put in more padding so we can add fields later. I strongly disagree putting in features now that we neither have a user, nor a usecase or testcase for.
So, how about another 64 bits of padding in struct
fiemap_extent? That could help cover future uses like compression, which might require another 64 bit offset field - we only have 32 bits of reserved space there right now.
I'd be happy to see it.
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Mark FashehQuoted 9 lines · Mark Fasheh
Quoted 4 lines · Christoph Hellwig
I agree to you (or someone elses - don't remember anymore) suggestion to put in more padding so we can add fields later. I strongly disagree putting in features now that we neither have a user, nor a usecase or testcase for.
So, how about another 64 bits of padding in struct
fiemap_extent? That could help cover future uses like compression, which might require another 64 bit offset field - we only have 32 bits of reserved space there right now.
What I'd recommend is a 56 byte structure:
struct fiemap_extent {
__u64 fe_logical; /* logical offset in bytes for the start of
* the extent from the beginning of the file */
__u64 fe_physical; /* physical offset in bytes for the start
* of the extent from the beginning of the disk */
__u64 fe_length; /* length in bytes for this extent */
__u64 fe_reserved64[2];
* encoded/compressed on disk */
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
__u32 fe_reserved[3];
};
Yeah, it's a little extra memory per extent, but filesystems seem to always invent new things, and it seem spretty clear that we have at least two extensions on deck (compression, multiple storage devices) both of which have at least one implementation that are either in the kernel or will likely enter the kernel. So it's likely that there is something that we may have missed, and leaving a little extra space doesn't actually cost us that much.
- Ted
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Andreas DilgerQuoted 8 lines · Andreas Dilger
The intent of this flag was a "catch-all" to indicate it isn't safe to try and read this block from disk, either because it is encrypted, compressed, on a remote system (HSM or over a network), or maybe not even written to disk yet (delalloc).
In some cases (e.g. dump on a snapshot, or boot with LILO) it IS ok to read directly from a block device underneath the filesystem, but that would completely fail for the above cases.
Indeed, I thought it was pretty clear and obvious, but let me give an quick but formal definition, and a potential name: DATA_ENCODED
If this flag is not set, then applications that who wish to access the file data may do so by accessing the block device at the indicated offset when the filesystem is unmounted. If the filesystem is mounted, it is undefined whether accessing via the block device will return valid data. If the flag DATA_ENCODED flag is set, it is almost certain that an application will never be able to access the file data via the block device.
Would this make people happy?
- Ted
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 6 lines · Theodore Tso
Quoted 5 lines · Andreas Dilger
The intent of this flag was a "catch-all" to indicate it isn't safe to try and read this block from disk, either because it is encrypted, compressed, on a remote system (HSM or over a network), or maybe not even written to disk yet (delalloc).
Quoted 8 lines
Quoted 3 lines
In some cases (e.g. dump on a snapshot, or boot with LILO) it IS ok to read directly from a block device underneath the filesystem, but that would completely fail for the above cases.
Indeed, I thought it was pretty clear and obvious, but let me give an quick but formal definition, and a potential name:
DATA_ENCODEDIf this flag is not set, then applications that who wish to access the
^^^^^^^^
Quoted 8 lines
file data may do so by accessing the block device at the indicated offset when the filesystem is unmounted. If the filesystem is mounted, it is undefined whether accessing via the block device will return valid data. If the flag
DATA_ENCODEDflag is set, it is almost certain that an application will never be able to access the file data via the block device.Would this make people happy?
Apart from the typo above, here is a more discouraging version:
In general, accessing the block device directly is strongly discouraged. Exceptions exist mainly in the form of boot loaders like lilo and grub, at a time when the filesystem is not (cannot be) mounted.
If the flag DATA_ENCODED is set, however, even this exception is no longer valid. The content is encoded in some form. Details are unknown, it could be compressed, encrypted or something else.
Jörn
Signature · 7 lines
Man darf nicht das, was uns unwahrscheinlich und unnatürlich erscheint, mit dem verwechseln, was absolut unmöglich ist. -- Carl Friedrich Gauß -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 9 lines · Jörn Engel
Apart from the typo above, here is a more discouraging version:
In general, accessing the block device directly is strongly discouraged. Exceptions exist mainly in the form of boot loaders like lilo and grub, at a time when the filesystem is not (cannot be) mounted.
If the flag
DATA_ENCODEDis set, however, even this exception is no longer valid. The content is encoded in some form. Details are unknown, it could be compressed, encrypted or something else.
I'm not clear about something from the above description.
If I were writing a journalling / tree-like filesystem, and I did store data in blocks without encoding, but fsync() only waits for them to be committed to journal, not their final destination, and also they might be moved around - should I set DATA_ENCODED or not? (And should I return the temporary location in the long-running journal since that's the only place the data is committed at the time of the call?)
Assume that even reading after unmounting is not 100% safe, because the data blocks could be relocated after calling FIEMAP (when the filesystem must be mounted), and before the unmount.
-- Jamie
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 9 lines · Jamie Lokier
I'm not clear about something from the above description.
If I were writing a journalling / tree-like filesystem, and I did store data in blocks without encoding, but
fsync()only waits for them to be committed to journal, not their final destination, and also they might be moved around - should I setDATA_ENCODEDor not? (And should I return the temporary location in the long-running journal since that's the only place the data is committed at the time of the call?)
I can imagine two ways of requiring this. One would be that you should only set DATA_ENCODED if you knew that the data had reached its final destination, possibly with some way of inducing the filesystem to wait until this had happened. The other approach would be to require in the specification that the filesystem would have to be unmounted at least once. I prefer the latter as it is much simpler, and the number of users who actually care about DATA_ENCODED is quite small.
The other observation I would make is that for filesystems where "final location" has no meaning (i.e., a log structured filesystem where its log cleaner is constantly moving data blocks around for compaction and/or flash wear leveling purposes), it will probably need to set some bit that means LOCATION_UNSTABLE, as well as setting DATA_ENCODED. This is would be a little confusing since what DATA_ENCODED really means is, "application that might want to read this file contents on an unmounted filesystem --- think again". So maybe a better name would be NO_UNMOUNTED_IO.
- Ted
P.S. If such filesystems want to be used by boot loaders that need fixed bootstrap blocks, they would probably need to have a flag that pinned the data blocks and caused them not be moved by the log cleaner. Reiser3 had to have something like this to work for LILO, but iirc this was just to disable tail packing. Same concept, though; it was a specialized per-filesystem flag that was needed if that filesystem wanted to be used by a particular boot loader with direct (unmounted) I/O requirements to access bootstrap code/data.
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Jamie LokierQuoted 20 lines · Jamie Lokier
Quoted 9 lines · Jörn Engel
Apart from the typo above, here is a more discouraging version:
In general, accessing the block device directly is strongly discouraged. Exceptions exist mainly in the form of boot loaders like lilo and grub, at a time when the filesystem is not (cannot be) mounted.
If the flag
DATA_ENCODEDis set, however, even this exception is no longer valid. The content is encoded in some form. Details are unknown, it could be compressed, encrypted or something else.I'm not clear about something from the above description.
If I were writing a journalling / tree-like filesystem, and I did store data in blocks without encoding, but
fsync()only waits for them to be committed to journal, not their final destination, and also they might be moved around - should I setDATA_ENCODEDor not? (And should I return the temporary location in the long-running journal since that's the only place the data is committed at the time of the call?)
Quoted 3 lines
Assume that even reading after unmounting is not 100% safe, because the data blocks could be relocated after calling FIEMAP (when the filesystem must be mounted), and before the unmount.
For the journal case at least, grub can walk through the log of the FS looking for up to date copies of things. It does this already for reiserfs because the btree can't be trusted at all without a log replay.
-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 21 lines · Chris Mason
Quoted 20 lines · Jamie Lokier
Quoted 9 lines · Jörn Engel
Apart from the typo above, here is a more discouraging version:
In general, accessing the block device directly is strongly discouraged. Exceptions exist mainly in the form of boot loaders like lilo and grub, at a time when the filesystem is not (cannot be) mounted.
If the flag
DATA_ENCODEDis set, however, even this exception is no longer valid. The content is encoded in some form. Details are unknown, it could be compressed, encrypted or something else.I'm not clear about something from the above description.
If I were writing a journalling / tree-like filesystem, and I did store data in blocks without encoding, but
fsync()only waits for them to be committed to journal, not their final destination, and also they might be moved around - should I setDATA_ENCODEDor not? (And should I return the temporary location in the long-running journal since that's the only place the data is committed at the time of the call?)
Quoted 7 lines
Quoted 3 lines
Assume that even reading after unmounting is not 100% safe, because the data blocks could be relocated after calling FIEMAP (when the filesystem must be mounted), and before the unmount.
For the journal case at least, grub can walk through the log of the FS looking for up to date copies of things. It does this already for reiserfs because the btree can't be trusted at all without a log replay.
Ok, that's good - grub doesn't need FIEMAP, it reads the filesystem properly.
So if I were writing a filesystem, what am I expected to return in FIEMAP for these cases? I'm thinking I should set DATA_ENCODED, even though the examples in Jörn's description don't cover this.
I'm thinking there are three main uses for FIEMAP:
1. LILO and similar. LILO itself is fine with FIBMAP though.
2. Fragmentation measurement and possibly defragmentation tools.
3. Something wants to have an idea of which areas of disk will be accessed, so it can optimise I/O at a higher level - i.e. a database. This isn't foolproof, especially for writes on recent filesystems which don't overwrite in place.
1 means DATA_ENCODED should be set whenever there's any likelihood that the result isn't reliable, so that would include when data is stored in a journal or other temporary place and not a permanent place on disk.
2 and 3 don't care about DATA_ENCODED at all.
-- Jamie
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 9 lines · Jamie Lokier
Quoted 8 lines · Chris Mason
Quoted 3 lines · Jamie Lokier
Assume that even reading after unmounting is not 100% safe, because the data blocks could be relocated after calling FIEMAP (when the filesystem must be mounted), and before the unmount.
For the journal case at least, grub can walk through the log of the FS looking for up to date copies of things. It does this already for reiserfs because the btree can't be trusted at all without a log replay.
OMFG.
Quoted 1 line
Ok, that's good - grub doesn't need FIEMAP, it reads the filesystem properly.
That's garbage. The whole point of using an API like FIEMAP is to avoid the problems with having to parse the raw disk structures to do stuff.
Grub has extremely hacky implementation of just the stuff it needs to read stuff directly off disk. The grub filesystem code is not reviewed by the various filesystem teams, it doesn't even use the same code as the filesystems, and last time I looked at it I came away with bleeding eyes and didn't want to look any further.
Why was I even looking at the grub code? Well, grub doesn't implement everyhting that is needed to parse XFS metadata structures. In particular, the problem was out-of-line symlinks in XFS, or traversing symlinks that point to symlinks was simply not implemented in the grub XFS code. Of course, this was considered to be an XFS problem, not a grub problem....
Not to mention that if we change the metadata disk format which is conditional on a superblock feature bit set at mkfs time, grub knows *nothing* about that new on disk format, how to parse it and will break horribly on such a filesystem.
All the APIs are there to prevent such problems that grub has. I just wish that they would be used rather than using grub's broken design as justification for not needing or using such APIs.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 7 lines · Dave Chinner
Quoted 6 lines · Jamie Lokier
Quoted 5 lines · Chris Mason
Quoted 3 lines · Jamie Lokier
Assume that even reading after unmounting is not 100% safe, because the data blocks could be relocated after calling FIEMAP (when the filesystem must be mounted), and before the unmount.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
For the journal case at least, grub can walk through the log of the FS looking for up to date copies of things. It does this already for reiserfs because the btree can't be trusted at all without a log replay.
OMFG.
Shrug, either we force the user to do something to get the blocks on disk in a stable location or we have a bootloader that can parse the disk format. It's either pain on the developers (patching grub) or pain on every user, and the support people who have to remind them to rerun grub-find-the-disk-blocks-just-like-lilo
-chris
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Dave ChinnerQuoted 7 lines · Dave Chinner
Quoted 6 lines · Jamie Lokier
Quoted 5 lines · Chris Mason
Quoted 3 lines · Jamie Lokier
Assume that even reading after unmounting is not 100% safe, because the data blocks could be relocated after calling FIEMAP (when the filesystem must be mounted), and before the unmount.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
For the journal case at least, grub can walk through the log of the FS looking for up to date copies of things. It does this already for reiserfs because the btree can't be trusted at all without a log replay.
OMFG.
Shrug, either we force the user to do something to get the blocks on disk in a stable location or we have a bootloader that can parse the disk format. It's either pain on the developers (patching grub) or pain on every user, and the support people who have to remind them to rerun grub-find-the-disk-blocks-just-like-lilo
-chris
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Chris MasonQuoted 10 lines · Chris Mason
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
For the journal case at least, grub can walk through the log of the FS looking for up to date copies of things. It does this already for reiserfs because the btree can't be trusted at all without a log replay.
OMFG.
Shrug, either we force the user to do something to get the blocks on disk in a stable location or we have a bootloader that can parse the disk format. It's either pain on the developers (patching grub) or pain on every user, and the support people who have to remind them to rerun grub-find-the-disk-blocks-just-like-lilo
I think this thread may be confusing /usr/bin/grub with grub the bootloader.
One of the useful features of grub the bootloader is that it can boot from a real filesystem without needing "run lilo before it's safe to boot - or you'll regret shutting down".
That feature needs to use some kind of bleeding-eyes filesystem code, or it will be as large as the filesystem code in Linux.
On the other hand, any dodgy direct access done by /usr/bin/grub has no justification and is fair game for deletion, imho.
-- Jamie
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 6 lines · Jamie Lokier
Quoted 5 lines
Shrug, either we force the user to do something to get the blocks on disk in a stable location or we have a bootloader that can parse the disk format. It's either pain on the developers (patching grub) or pain on every user, and the support people who have to remind them to rerun grub-find-the-disk-blocks-just-like-lilo
Quoted 8 lines
I think this thread may be confusing
/usr/bin/grubwith grub the bootloader.One of the useful features of grub the bootloader is that it can boot from a real filesystem without needing "run lilo before it's safe to boot - or you'll regret shutting down".
That feature needs to use some kind of bleeding-eyes filesystem code, or it will be as large as the filesystem code in Linux.
If the lilo or grub approach is better is at least debatable, but that's not really the point here.
Quoted 2 lines
On the other hand, any dodgy direct access done by
/usr/bin/grubhas no justification and is fair game for deletion, imho.
That _is_ the real problem. But we're getting quite offtopic as non of that is related to FIEMAP anymore ;-)
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
In reply to Theodore TsoQuoted 7 lines · Theodore Tso
Quoted 6 lines · Mark Fasheh
Quoted 4 lines · Christoph Hellwig
I agree to you (or someone elses - don't remember anymore) suggestion to put in more padding so we can add fields later. I strongly disagree putting in features now that we neither have a user, nor a usecase or testcase for.
Quoted 5 lines
Quoted 3 lines
So, how about another 64 bits of padding in struct
fiemap_extent? That could help cover future uses like compression, which might require another 64 bit offset field - we only have 32 bits of reserved space there right now.What I'd recommend is a 56 byte structure:
Why not just make it 64 bytes? Sure, that's 8 extra bytes, but I find the power-of-2 size (and the extra space) comforting. (AFAIK, slab allocators will give you 64 bytes anyway; and I expect something similar on the user-space side of things.)
...
Quoted 7 lines
Yeah, it's a little extra memory per extent, but filesystems seem to always invent new things, and it seem spretty clear that we have at least two extensions on deck (compression, multiple storage devices) both of which have at least one implementation that are either in the kernel or will likely enter the kernel. So it's likely that there is something that we may have missed, and leaving a little extra space doesn't actually cost us that much.
Right.
Josef 'Jeff' Sipek.
Signature · 2 lines
Once you have their hardware. Never give it back. (The First Rule of Hardware Acquisition)
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
Mark,
Do you have time to update the fiemap patchset so we can hopefully come to consensus and get this pushed to Linus in time for the upcoming merge window?
If not, I can take over for you and take over the care and feeding of this patchset so it can get pushed to Linus ASAP; I think we are pretty close to consensus on this interface, and I'd rather that we not lose momentum.
- Ted
Re: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 3 lines · Theodore Tso
Do you have time to update the fiemap patchset so we can hopefully come to consensus and get this pushed to Linus in time for the upcoming merge window?
I can probably do this early next week. If that's not soon enough, I won't be offended if you or someone else does the update. I agree, it seems like we're pretty close to consensus.
Quoted 4 lines
If not, I can take over for you and take over the care and feeding of this patchset so it can get pushed to Linus ASAP; I think we are pretty close to consensus on this interface, and I'd rather that we not lose momentum.
Why not let this sit in -mm for a cycle? I know how that sounds, considering how long it's taken everyone to decide what color to paint the bicycle shed, but at the least it'd give other file systems a chance to write their own support patches. There's also the benefit of a little extra time for ext4/ocfs2 to debug their own support patches. Do we lose any momentum if the patches are 'complete' and in -mm with a target for 2.6.29?
--Mark
--
Mark Fasheh
Theodore Tso
maintainerRe: [PATCH 1/4] vfs: vfs-level fiemap interface
Quoted 6 lines · Mark Fasheh
Why not let this sit in -mm for a cycle? I know how that sounds, considering how long it's taken everyone to decide what color to paint the bicycle shed, but at the least it'd give other file systems a chance to write their own support patches. There's also the benefit of a little extra time for ext4/ocfs2 to debug their own support patches. Do we lose any momentum if the patches are 'complete' and in -mm with a target for 2.6.29?
Quite frankly, the reason why I'd rather not is because I'd rather not have someone else showing up asking what color to paint the bicycle shed. We don't have to have all filesystems with support patches before we merge the core patches; in fact I don't think there's any real benefit in holding back until other filesystems are ready. At least the ext4 patches has been ready for quite some time --- and getting it merged would help us with our online defrag patches.
- Ted