Skip to content

Commit 17cf28a

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm/fs: remove truncate_range
Remove vmtruncate_range(), and remove the truncate_range method from struct inode_operations: only tmpfs ever supported it, and tmpfs has now converted over to using the fallocate method of file_operations. Update Documentation accordingly, adding (setlease and) fallocate lines. And while we're in mm.h, remove duplicate declarations of shmem_lock() and shmem_file_setup(): everyone is now using the ones in shmem_fs.h. Based-on-patch-by: Cong Wang <amwang@redhat.com> Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Cong Wang <amwang@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3f31d07 commit 17cf28a

File tree

7 files changed

+8
-39
lines changed

7 files changed

+8
-39
lines changed

Documentation/filesystems/Locking

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ ata *);
6060
ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
6161
ssize_t (*listxattr) (struct dentry *, char *, size_t);
6262
int (*removexattr) (struct dentry *, const char *);
63-
void (*truncate_range)(struct inode *, loff_t, loff_t);
6463
int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
6564

6665
locking rules:
@@ -87,7 +86,6 @@ setxattr: yes
8786
getxattr: no
8887
listxattr: no
8988
removexattr: yes
90-
truncate_range: yes
9189
fiemap: no
9290
Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
9391
victim.

Documentation/filesystems/vfs.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ struct inode_operations {
363363
ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
364364
ssize_t (*listxattr) (struct dentry *, char *, size_t);
365365
int (*removexattr) (struct dentry *, const char *);
366-
void (*truncate_range)(struct inode *, loff_t, loff_t);
367366
};
368367

369368
Again, all methods are called without any locks being held, unless
@@ -472,9 +471,6 @@ otherwise noted.
472471
removexattr: called by the VFS to remove an extended attribute from
473472
a file. This method is called by removexattr(2) system call.
474473

475-
truncate_range: a method provided by the underlying filesystem to truncate a
476-
range of blocks , i.e. punch a hole somewhere in a file.
477-
478474

479475
The Address Space Object
480476
========================
@@ -760,7 +756,7 @@ struct file_operations
760756
----------------------
761757

762758
This describes how the VFS can manipulate an open file. As of kernel
763-
2.6.22, the following members are defined:
759+
3.5, the following members are defined:
764760

765761
struct file_operations {
766762
struct module *owner;
@@ -790,6 +786,8 @@ struct file_operations {
790786
int (*flock) (struct file *, int, struct file_lock *);
791787
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int);
792788
ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);
789+
int (*setlease)(struct file *, long arg, struct file_lock **);
790+
long (*fallocate)(struct file *, int mode, loff_t offset, loff_t len);
793791
};
794792

795793
Again, all methods are called without any locks being held, unless
@@ -858,6 +856,11 @@ otherwise noted.
858856
splice_read: called by the VFS to splice data from file to a pipe. This
859857
method is used by the splice(2) system call
860858

859+
setlease: called by the VFS to set or release a file lock lease.
860+
setlease has the file_lock_lock held and must not sleep.
861+
862+
fallocate: called by the VFS to preallocate blocks or punch a hole.
863+
861864
Note that the file operations are implemented by the specific
862865
filesystem in which the inode resides. When opening a device node
863866
(character or block special) most filesystems will call special

fs/bad_inode.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ static const struct inode_operations bad_inode_ops =
292292
.getxattr = bad_inode_getxattr,
293293
.listxattr = bad_inode_listxattr,
294294
.removexattr = bad_inode_removexattr,
295-
/* truncate_range returns void */
296295
};
297296

298297

include/linux/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,6 @@ struct inode_operations {
16811681
ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
16821682
ssize_t (*listxattr) (struct dentry *, char *, size_t);
16831683
int (*removexattr) (struct dentry *, const char *);
1684-
void (*truncate_range)(struct inode *, loff_t, loff_t);
16851684
int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
16861685
u64 len);
16871686
} ____cacheline_aligned;

include/linux/mm.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,6 @@ extern void pagefault_out_of_memory(void);
871871
extern void show_free_areas(unsigned int flags);
872872
extern bool skip_free_areas_node(unsigned int flags, int nid);
873873

874-
int shmem_lock(struct file *file, int lock, struct user_struct *user);
875-
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
876874
int shmem_zero_setup(struct vm_area_struct *);
877875

878876
extern int can_do_mlock(void);
@@ -951,11 +949,9 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping,
951949
extern void truncate_pagecache(struct inode *inode, loff_t old, loff_t new);
952950
extern void truncate_setsize(struct inode *inode, loff_t newsize);
953951
extern int vmtruncate(struct inode *inode, loff_t offset);
954-
extern int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end);
955952
void truncate_pagecache_range(struct inode *inode, loff_t offset, loff_t end);
956953
int truncate_inode_page(struct address_space *mapping, struct page *page);
957954
int generic_error_remove_page(struct address_space *mapping, struct page *page);
958-
959955
int invalidate_inode_page(struct page *page);
960956

961957
#ifdef CONFIG_MMU

mm/shmem.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,6 @@ static const struct file_operations shmem_file_operations = {
25412541

25422542
static const struct inode_operations shmem_inode_operations = {
25432543
.setattr = shmem_setattr,
2544-
.truncate_range = shmem_truncate_range,
25452544
#ifdef CONFIG_TMPFS_XATTR
25462545
.setxattr = shmem_setxattr,
25472546
.getxattr = shmem_getxattr,

mm/truncate.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -602,31 +602,6 @@ int vmtruncate(struct inode *inode, loff_t newsize)
602602
}
603603
EXPORT_SYMBOL(vmtruncate);
604604

605-
int vmtruncate_range(struct inode *inode, loff_t lstart, loff_t lend)
606-
{
607-
struct address_space *mapping = inode->i_mapping;
608-
loff_t holebegin = round_up(lstart, PAGE_SIZE);
609-
loff_t holelen = 1 + lend - holebegin;
610-
611-
/*
612-
* If the underlying filesystem is not going to provide
613-
* a way to truncate a range of blocks (punch a hole) -
614-
* we should return failure right now.
615-
*/
616-
if (!inode->i_op->truncate_range)
617-
return -ENOSYS;
618-
619-
mutex_lock(&inode->i_mutex);
620-
inode_dio_wait(inode);
621-
unmap_mapping_range(mapping, holebegin, holelen, 1);
622-
inode->i_op->truncate_range(inode, lstart, lend);
623-
/* unmap again to remove racily COWed private pages */
624-
unmap_mapping_range(mapping, holebegin, holelen, 1);
625-
mutex_unlock(&inode->i_mutex);
626-
627-
return 0;
628-
}
629-
630605
/**
631606
* truncate_pagecache_range - unmap and remove pagecache that is hole-punched
632607
* @inode: inode

0 commit comments

Comments
 (0)