Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: convert to generic_file_llseek

There's no reason we need to lock the inode for write in order to handle
an llseek. I suspect this should have been dropped in 2013 when we
stopped doing vmtruncate in llseek.

With that gone, ceph_llseek is functionally equivalent to
generic_file_llseek, so just call that after getting the size.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Luís Henriques <lhenriques@suse.de>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Jeff Layton and committed by
Ilya Dryomov
e8214503 1b7587d6

+5 -47
+5 -47
fs/ceph/file.c
··· 1939 1939 */ 1940 1940 static loff_t ceph_llseek(struct file *file, loff_t offset, int whence) 1941 1941 { 1942 - struct inode *inode = file->f_mapping->host; 1943 - struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 1944 - loff_t i_size; 1945 - loff_t ret; 1946 - 1947 - inode_lock(inode); 1948 - 1949 1942 if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) { 1943 + struct inode *inode = file_inode(file); 1944 + int ret; 1945 + 1950 1946 ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); 1951 1947 if (ret < 0) 1952 - goto out; 1948 + return ret; 1953 1949 } 1954 - 1955 - i_size = i_size_read(inode); 1956 - switch (whence) { 1957 - case SEEK_END: 1958 - offset += i_size; 1959 - break; 1960 - case SEEK_CUR: 1961 - /* 1962 - * Here we special-case the lseek(fd, 0, SEEK_CUR) 1963 - * position-querying operation. Avoid rewriting the "same" 1964 - * f_pos value back to the file because a concurrent read(), 1965 - * write() or lseek() might have altered it 1966 - */ 1967 - if (offset == 0) { 1968 - ret = file->f_pos; 1969 - goto out; 1970 - } 1971 - offset += file->f_pos; 1972 - break; 1973 - case SEEK_DATA: 1974 - if (offset < 0 || offset >= i_size) { 1975 - ret = -ENXIO; 1976 - goto out; 1977 - } 1978 - break; 1979 - case SEEK_HOLE: 1980 - if (offset < 0 || offset >= i_size) { 1981 - ret = -ENXIO; 1982 - goto out; 1983 - } 1984 - offset = i_size; 1985 - break; 1986 - } 1987 - 1988 - ret = vfs_setpos(file, offset, max(i_size, fsc->max_file_size)); 1989 - 1990 - out: 1991 - inode_unlock(inode); 1992 - return ret; 1950 + return generic_file_llseek(file, offset, whence); 1993 1951 } 1994 1952 1995 1953 static inline void ceph_zero_partial_page(