Commit 79dbe46d authored by Christian Mohrbacher's avatar Christian Mohrbacher

updated to release 6.1

parent 634f4e52
......@@ -158,6 +158,10 @@ $(call define_if_matches, KERNEL_HAS_LIST_IS_LAST, "list_is_last", list.h)
# Note: Added to vanilla 3.16, but backported e.g. to Oracle uek 3.8
$(call define_if_matches, KERNEL_HAS_DIRECT_IO_ITER, -E "(\*direct_IO).*struct iov_iter", fs.h)
# Find out if the kernel has a special struct iov_iter (which does not contain an iov pointer) which
# only seems to exist in Oracle uek kernels.
$(call define_if_matches, KERNEL_HAS_SPECIAL_UEK_IOV_ITER, -F "struct iovec *iov_iter_iovec", fs.h)
# Find out if the kernel has f_dentry as part of struct dentry or a f_dentry define for
# f_path.dentry.
$(call define_if_matches, KERNEL_HAS_F_DENTRY, "f_dentry", fs.h)
......@@ -267,98 +271,3 @@ KERNEL_FEATURE_DETECTION += $(shell \
grep -sFA1 "sock_recvmsg" ${KSRCDIR_PRUNED_HEAD}/include/linux/net.h \
| grep -qsF "size_t size" \
&& echo "-DKERNEL_HAS_RECVMSG_SIZE")
$(call define_if_matches, KERNEL_HAS_MEMDUP_USER, "memdup_user", string.h)
$(call define_if_matches, KERNEL_HAS_CURRENT_FSUID, "current_fsuid", cred.h)
$(call define_if_matches, KERNEL_HAS_FIRST_NET_DEVICE_NS, "first_net_device.struct net", \
netdevice.h)
$(call define_if_matches, KERNEL_HAS_FIRST_NET_DEVICE, "first_net_device.void.", netdevice.h)
$(call define_if_matches, KERNEL_HAS_FAULTATTR_DNAME, -F "struct dentry *dname", fault-inject.h)
$(call define_if_matches, KERNEL_HAS_MNT_WANT_WRITE, "mnt_want_write", mount.h)
$(call define_if_matches, KERNEL_HAS_SYSTEM_UTSNAME, "system_utsname", utsname.h)
$(call define_if_matches, KERNEL_HAS_IN4_PTON, "in4_pton", inet.h)
$(call define_if_matches, KERNEL_HAS_KSTRNDUP, "kstrndup", string.h)
$(call define_if_matches, KERNEL_HAS_SOCK_CREATE_KERN_NS, "sock_create_kern.struct net", net.h)
$(call define_if_matches, KERNEL_HAS_SOCK_SENDMSG_NOLEN, "sock_sendmsg.*msg.;", net.h)
$(call define_if_matches, KERNEL_HAS_MSGHDR_ITER, "msg_iter", socket.h)
$(call define_if_matches, KERNEL_HAS_IOV_ITER_INIT_DIR, "iov_iter_init.*direction", uio.h)
$(call define_if_matches, KERNEL_HAS_ITER_BVEC, "ITER_BVEC", uio.h)
$(call define_if_matches, KERNEL_HAS_ITER_IS_IOVEC, "iter_is_iovec", uio.h)
$(call define_if_matches, KERNEL_HAS_IOV_ITER_IN_FS, "struct iov_iter {", fs.h)
$(call define_if_matches, KERNEL_HAS_IOV_ITER_IOVEC, "iov_iter_iovec", uio.h)
$(call define_if_matches, KERNEL_HAS_GET_SB_NODEV, "get_sb_nodev", fs.h)
$(call define_if_matches, KERNEL_HAS_GENERIC_FILE_LLSEEK_UNLOCKED, "generic_file_llseek_unlocked", \
fs.h)
$(call define_if_matches, KERNEL_HAS_SET_NLINK, "set_nlink", fs.h)
$(call define_if_matches, KERNEL_HAS_DENTRY_PATH_RAW, "dentry_path_raw", dcache.h)
$(call define_if_matches, KERNEL_HAS_MAPPING_SET_ERROR, "mapping_set_error", pagemap.h)
$(call define_if_matches, KERNEL_HAS_PREPARE_WRITE, -F "(*prepare_write)", fs.h)
$(call define_if_matches, KERNEL_HAS_FSYNC_DENTRY, -P "(\*fsync).*dentry", fs.h)
$(call define_if_matches, KERNEL_HAS_ITER_FILE_SPLICE_WRITE, "iter_file_splice_write", fs.h)
$(call define_if_matches, KERNEL_HAS_ITER_GENERIC_FILE_SENDFILE, "generic_file_sendfile", fs.h)
$(call define_if_matches, KERNEL_HAS_ITERATE_DIR, "iterate_dir", fs.h)
$(call define_if_matches, KERNEL_HAS_ENCODE_FH_INODE, -P "\(\*encode_fh\).struct inode", exportfs.h)
$(call define_if_matches, KERNEL_HAS_D_DELETE_CONST_ARG, \
-F "int (*d_delete)(const struct dentry *);", dcache.h)
$(call define_if_matches, KERNEL_HAS_FILE_F_VFSMNT, -P "struct vfsmount\s*\*f_vfsmnt", fs.h)
$(call define_if_matches, KERNEL_HAS_POSIX_ACL_XATTR_USERNS_ARG, \
-P "posix_acl_from_xattr.struct user_namespace", posix_acl_xattr.h)
$(call define_if_matches, KERNEL_HAS_D_MAKE_ROOT, d_make_root, dcache.h)
$(call define_if_matches, KERNEL_HAS_GENERIC_WRITE_CHECKS_ITER, \
-P "generic_write_checks.*iov_iter", fs.h)
$(call define_if_matches, KERNEL_HAS_GENERIC_PERMISSION_2, \
-P "extern int generic_permission\(struct inode \*. int\);", fs.h)
# fourth arg is a callback on the next line.
$(call define_if_matches, KERNEL_HAS_GENERIC_PERMISSION_4, \
-P "extern int generic_permission.struct inode \*. int. unsigned int.", fs.h)
$(call define_if_matches, KERNEL_HAS_WRITE_ITER, -F "ssize_t (*write_iter)", fs.h)
$(call define_if_matches, KERNEL_HAS_AIO_WRITE_BUF, \
-P "ssize_t \(\*aio_write\).*const char", fs.h)
KERNEL_FEATURE_DETECTION += $(shell \
grep -sFB20 "launder_page" ${KSRCDIR_PRUNED_HEAD}/include/linux/fs.h \
| grep -LF "address_space_operations_ext" | grep -qsvF "input" \
&& echo "-DKERNEL_HAS_LAUNDER_PAGE")
$(call define_if_matches, KERNEL_HAS_INVALIDATEPAGE_RANGE, \
-P "void \(\*invalidatepage\) \(struct page \*. unsigned int. unsigned int\);", fs.h)
$(call define_if_matches, KERNEL_HAS_PERMISSION_2, \
-P "int \(\*permission\) \(struct inode \*. int\);", fs.h)
$(call define_if_matches, KERNEL_HAS_PERMISSION_FLAGS, \
-P "int \(\*permission\) \(struct inode \*. int. unsigned int\);", fs.h)
KERNEL_FEATURE_DETECTION += $(shell \
grep -sFA5 "kmem_cache_create" ${KSRCDIR_PRUNED_HEAD}/include/linux/slab.h \
| grep -qsF "void (*)(void *, struct kmem_cache *, unsigned long)" \
&& echo "-DKERNEL_HAS_KMEMCACHE_CACHE_FLAGS_CTOR")
KERNEL_FEATURE_DETECTION += $(shell \
grep -sFA5 "kmem_cache_create" ${KSRCDIR_PRUNED_HEAD}/include/linux/slab.h \
| grep -qsF "void (*)(struct kmem_cache *, void *)" \
&& echo "-DKERNEL_HAS_KMEMCACHE_CACHE_CTOR")
KERNEL_FEATURE_DETECTION += $(shell \
grep -sFA5 "kmem_cache_create" ${KSRCDIR_PRUNED_HEAD}/include/linux/slab.h \
| grep -qsxP "\s+void \(\*\)\(.*?\)," \
&& echo "-DKERNEL_HAS_KMEMCACHE_DTOR")
$(call define_if_matches, KERNEL_HAS_PROC_CREATE_DATA, -F "proc_create_data", proc_fs.h)
$(call define_if_matches, KERNEL_HAS_SB_BDI, -F "struct backing_dev_info *s_bdi", fs.h)
$(call define_if_matches, KERNEL_HAS_BDI_SETUP_AND_REGISTER, "bdi_setup_and_register", \
backing-dev.h)
$(call define_if_matches, KERNEL_HAS_FOLLOW_LINK_COOKIE, \
-P "const char \* \(\*follow_link\) \(struct dentry \*. void \*\*\);", fs.h)
$(call define_if_matches, KERNEL_HAS_FILEMAP_WRITE_AND_WAIT_RANGE, "filemap_write_and_wait_range", \
fs.h)
$(call define_if_matches, KERNEL_HAS_FSYNC_2, \
-F "int (*fsync) (struct file *, int datasync);", fs.h)
KERNEL_FEATURE_DETECTION += $(shell \
grep -sFA20 "struct address_space {" ${KSRCDIR_PRUNED_HEAD}/include/linux/fs.h \
| grep -qsP "struct backing_dev_info *backing_dev_info;" \
&& echo "-DKERNEL_HAS_ADDRESS_SPACE_BDI")
$(call define_if_matches, KERNEL_HAS_SET_ACL, \
-P "int \(\*set_acl\)\(struct inode \*. struct posix_acl \*. int\);", fs.h)
$(call define_if_matches, KERNEL_HAS_IOCB_DIRECT, "IOCB_DIRECT", fs.h)
KERNEL_FEATURE_DETECTION += $(shell \
grep -sPA1 "generic_file_direct_write.*,$$" \
${KSRCDIR_PRUNED_HEAD}/include/linux/fs.h \
| grep -qsF "loff_t *" \
&& echo "-DKERNEL_HAS_GENERIC_FILE_DIRECT_WRITE_POSP")
$(call define_if_matches, KERNEL_HAS_COPY_FROM_ITER, "copy_from_iter", uio.h)
$(call define_if_matches, KERNEL_HAS_INIT_WORK_2, -F "INIT_WORK(_work, _func)", workqueue.h)
$(call define_if_matches, KERNEL_HAS_ALLOC_WORKQUEUE, "alloc_workqueue", workqueue.h)
$(call define_if_matches, KERNEL_HAS_WQ_RESCUER, "WQ_RESCUER", workqueue.h)
......@@ -492,7 +492,7 @@ bool __App_initInodeOperations(App* this)
this->fileInodeOps->get_acl = FhgfsOps_get_acl;
this->dirInodeOps->get_acl = FhgfsOps_get_acl;
// Note: symlinks don't have ACLs
#ifdef KERNEL_HAS_SET_ACL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
this->fileInodeOps->set_acl = FhgfsOps_set_acl;
this->dirInodeOps->set_acl = FhgfsOps_set_acl;
#endif // LINUX_VERSION_CODE
......
......@@ -142,7 +142,7 @@
// get effective ID of current FS user/group access
#if !defined(KERNEL_HAS_CURRENT_FSUID)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
#define currentFsUserID (current->fsuid)
#define currentFsGroupID (current->fsgid)
#else
......
......@@ -24,9 +24,9 @@ static int __NIC_sockIoctlV2(struct socket* sock, int cmd, unsigned long arg);
static struct net_device* __first_netdev(void)
{
#if !defined(KERNEL_HAS_FIRST_NET_DEVICE) && !defined(KERNEL_HAS_FIRST_NET_DEVICE_NS)
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
return dev_base;
#elif defined(KERNEL_HAS_FIRST_NET_DEVICE)
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
return first_net_device();
#else
return first_net_device(&init_net);
......@@ -35,7 +35,7 @@ static struct net_device* __first_netdev(void)
static struct net_device* __next_netdev(struct net_device* currentDev)
{
#if !defined(KERNEL_HAS_FIRST_NET_DEVICE) && !defined(KERNEL_HAS_FIRST_NET_DEVICE_NS)
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
return currentDev->next;
#else
return next_net_device(currentDev);
......
......@@ -101,7 +101,7 @@ bool _StandardSocket_initSock(StandardSocket* this, int domain, int type, int pr
int createRes;
// prepare/create socket
#ifndef KERNEL_HAS_SOCK_CREATE_KERN_NS
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
createRes = sock_create_kern(domain, type, protocol, &this->sock);
#else
createRes = sock_create_kern(&init_net, domain, type, protocol, &this->sock);
......@@ -562,8 +562,8 @@ ssize_t _StandardSocket_sendto(Socket* this, struct iov_iter* iter, int flags,
.msg_namelen = sizeof(toSockAddr),
};
#ifndef KERNEL_HAS_MSGHDR_ITER
struct iovec iov = iov_iter_iovec(iter);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
struct iovec iov = BEEGFS_IOV_ITER_IOVEC(iter);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
......@@ -582,7 +582,7 @@ ssize_t _StandardSocket_sendto(Socket* this, struct iov_iter* iter, int flags,
ACQUIRE_PROCESS_CONTEXT(oldfs);
#ifndef KERNEL_HAS_SOCK_SENDMSG_NOLEN
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
sendRes = sock_sendmsg(thisCast->sock, &msg, len);
#else
sendRes = sock_sendmsg(thisCast->sock, &msg);
......@@ -614,8 +614,8 @@ ssize_t StandardSocket_recvfrom(StandardSocket* this, struct iov_iter* iter, int
.msg_namelen = sizeof(fromSockAddr),
};
#ifndef KERNEL_HAS_MSGHDR_ITER
struct iovec iov = iov_iter_iovec(iter);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
struct iovec iov = BEEGFS_IOV_ITER_IOVEC(iter);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
......
......@@ -15,7 +15,7 @@ char* System_getHostnameCopy(void)
down_read(&uts_sem);
#endif
#ifdef KERNEL_HAS_SYSTEM_UTSNAME
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
hostnameOrig = system_utsname.nodename;
#else
hostnameOrig = utsname()->nodename;
......
......@@ -187,7 +187,7 @@ bool SocketTk_getHostByName(struct ExternalHelperd* helperd, const char* hostnam
*/
bool SocketTk_getHostByAddrStr(const char* hostAddr, struct in_addr* outIPAddr)
{
#ifndef KERNEL_HAS_IN4_PTON
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,19)
outIPAddr->s_addr = in_aton(hostAddr); // this version has no error handling
#else
if(unlikely(!in4_pton(hostAddr, strlen(hostAddr), (u8 *)outIPAddr, -1, NULL) ) )
......
......@@ -91,7 +91,7 @@ char* StringTk_strDup(const char* s)
*/
char* StringTk_strnDup(const char* s, size_t len)
{
#ifndef KERNEL_HAS_KSTRNDUP
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
return kstrdup(s, GFP_NOFS);
#else
return kstrndup(s, len, GFP_NOFS);
......
......@@ -26,7 +26,7 @@ BEEGFS_DECLARE_FAULT_ATTR(commkit_writefile_senddata_timeout);
if(IS_ERR(fault_create_debugfs_attr(#name, fault_dir, &beegfs_fault_ ## name))) \
goto err_fault_dir;
#ifndef KERNEL_HAS_FAULTATTR_DNAME
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
#define DESTROY_FAULT(name) do { } while (0)
#else
#define DESTROY_FAULT(name) \
......
......@@ -55,7 +55,7 @@ int FhgfsOps_revalidateIntent(struct dentry* dentry, unsigned flags)
#endif // LINUX_VERSION_CODE
#ifdef LOOKUP_RCU
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
/* note: 2.6.38 introduced rcu-walk mode, which is inappropriate for us, because we need the
parentDentry and need to sleep for communication. ECHILD below tells vfs to call this again
in old ref-walk mode. (see Documentation/filesystems/vfs.txt:d_revalidate) */
......@@ -232,7 +232,7 @@ out:
*
* @return !=0 to delete dentry, 0 to keep it
*/
#ifndef KERNEL_HAS_D_DELETE_CONST_ARG
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37)
int FhgfsOps_deleteDentry(struct dentry* dentry)
#else
int FhgfsOps_deleteDentry(const struct dentry* dentry)
......
......@@ -26,7 +26,7 @@ extern struct dentry_operations fhgfs_dentry_ops;
extern int FhgfsOps_revalidateIntent(struct dentry* dentry, unsigned flags);
#endif // LINUX_VERSION_CODE
#ifndef KERNEL_HAS_D_DELETE_CONST_ARG
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37)
extern int FhgfsOps_deleteDentry(struct dentry* dentry);
#else
extern int FhgfsOps_deleteDentry(const struct dentry* dentry);
......
......@@ -81,7 +81,7 @@ typedef enum FhgfsNfsHandleType FhgfsNfsHandleType;
*
* @return FhgfsNfsHandleType_...
*/
#ifndef KERNEL_HAS_ENCODE_FH_INODE
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
int FhgfsOpsExport_encodeNfsFileHandle(struct dentry* dentry, __u32* file_handle_buf, int* max_len,
int connectable)
......
......@@ -24,7 +24,7 @@ struct FhgfsNfsFileHandleV3;
extern const struct export_operations fhgfs_export_ops;
#ifndef KERNEL_HAS_ENCODE_FH_INODE
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
int FhgfsOpsExport_encodeNfsFileHandle(struct dentry* dentry, __u32* file_handle_buf, int* max_len,
int connectable);
#else
......
......@@ -46,7 +46,7 @@ extern loff_t FhgfsOps_llseek(struct file *file, loff_t offset, int origin);
extern int FhgfsOps_opendirIncremental(struct inode* inode, struct file* file);
extern int FhgfsOps_releasedir(struct inode* inode, struct file* file);
#ifdef KERNEL_HAS_ITERATE_DIR
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
extern int FhgfsOps_iterateIncremental(struct file* file, struct dir_context* ctx);
#else
extern int FhgfsOps_readdirIncremental(struct file* file, void* buf, filldir_t filldir);
......@@ -60,7 +60,7 @@ extern int FhgfsOps_release(struct inode* inode, struct file* file);
#ifdef KERNEL_HAS_FSYNC_RANGE /* added in vanilla 3.1 */
int FhgfsOps_fsync(struct file* file, loff_t start, loff_t end, int datasync);
#elif !defined(KERNEL_HAS_FSYNC_DENTRY)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
int FhgfsOps_fsync(struct file* file, int datasync);
#else
/* LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) */
......@@ -80,11 +80,11 @@ extern ssize_t FhgfsOps_read(struct file* file, char __user *buf, size_t size,
extern ssize_t FhgfsOps_write(struct file* file, const char __user *buf, size_t size,
loff_t* offsetPointer);
#if defined(KERNEL_HAS_AIO_WRITE_BUF)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
extern ssize_t FhgfsOps_aio_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos);
extern ssize_t FhgfsOps_aio_write(struct kiocb *iocb, const char __user *buf, size_t count,
loff_t pos);
#elif !defined(KERNEL_HAS_WRITE_ITER)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
extern ssize_t FhgfsOps_aio_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos);
extern ssize_t FhgfsOps_aio_write(struct kiocb *iocb, const struct iovec *iov,
......@@ -96,7 +96,7 @@ extern ssize_t FhgfsOps_write(struct file* file, const char __user *buf, size_t
extern int FhgfsOps_mmap(struct file *, struct vm_area_struct *);
#ifdef KERNEL_HAS_PREPARE_WRITE
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
extern int FhgfsOps_prepare_write(struct file *file, struct page *page, unsigned from,
unsigned to);
extern int FhgfsOps_commit_write(struct file *file, struct page *page, unsigned from,
......
......@@ -28,9 +28,9 @@ bool beegfs_native_init()
readpages_init();
#ifndef KERNEL_HAS_ALLOC_WORKQUEUE
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
remoting_io_queue = create_workqueue("beegfs/flush");
#elif defined(KERNEL_HAS_WQ_RESCUER)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
// WQ_RESCUER and WQ_MEM_RECLAIM are effectively the same thing: they ensure that
// at least one thread to run work items on is always available.
remoting_io_queue = alloc_workqueue("beegfs/flush", WQ_RESCUER, num_online_cpus());
......@@ -315,7 +315,7 @@ static int beegfs_release_range(struct file* filp, loff_t first, loff_t last)
clear_bit(AS_EIO, &filp->f_mapping->flags);
#if !defined(KERNEL_HAS_FILEMAP_WRITE_AND_WAIT_RANGE)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
writeRes = filemap_write_and_wait(filp->f_mapping);
#else
writeRes = filemap_write_and_wait_range(filp->f_mapping, first, last);
......@@ -463,22 +463,17 @@ static int beegfs_release(struct inode* inode, struct file* filp)
return FhgfsOps_release(inode, filp);
}
#if defined(KERNEL_HAS_AIO_WRITE_BUF)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
static ssize_t beegfs_file_write_iter(struct kiocb* iocb, struct iov_iter* from)
{
struct iovec iov = iov_iter_iovec(from);
struct iovec iov = BEEGFS_IOV_ITER_IOVEC(from);
return generic_file_aio_write(iocb, iov.iov_base, iov.iov_len, iocb->ki_pos);
}
#elif !defined(KERNEL_HAS_WRITE_ITER)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
static ssize_t beegfs_file_write_iter(struct kiocb* iocb, struct iov_iter* from)
{
struct iovec iov = iov_iter_iovec(from);
if (from->iov_offset == 0)
return generic_file_aio_write(iocb, from->iov, from->nr_segs, iocb->ki_pos);
else
return generic_file_aio_write(iocb, &iov, 1, iocb->ki_pos);
return generic_file_aio_write(iocb, BEEGFS_IOV_ITER_RAW(from), from->nr_segs, iocb->ki_pos);
}
#else
static ssize_t beegfs_file_write_iter(struct kiocb* iocb, struct iov_iter* from)
......@@ -584,7 +579,6 @@ static ssize_t beegfs_append_iter(struct kiocb* iocb, struct iov_iter* from)
static ssize_t beegfs_write_iter(struct kiocb* iocb, struct iov_iter* from)
{
struct file* filp = iocb->ki_filp;
size_t size = from->count;
......@@ -605,7 +599,7 @@ static ssize_t beegfs_write_iter(struct kiocb* iocb, struct iov_iter* from)
{
ssize_t result;
#ifdef KERNEL_HAS_IOCB_DIRECT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0)
iocb->ki_flags |= IOCB_DIRECT;
result = generic_file_write_iter(iocb, from);
#else
......@@ -633,24 +627,16 @@ static ssize_t beegfs_write_iter(struct kiocb* iocb, struct iov_iter* from)
if(result)
break;
#ifndef KERNEL_HAS_WRITE_ITER
/* if we ever *do* get an iterator with a non-zero iov_offset, warn and fail. we should
* never get one of these, because iov_iter appeared in 3.16. anything that does create
* such an iterator must have originated in this file.
*/
if (unlikely(from->iov_offset > 0))
{
WARN_ON(1);
result = -EINVAL;
}
else
{
result = generic_file_direct_write(iocb, from->iov, &from->nr_segs, pos,
#ifdef KERNEL_HAS_GENERIC_FILE_DIRECT_WRITE_POSP
&iocb->ki_pos,
#endif
size, size);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
/* this is a really ass-backwards of doing this. _ITER_RAW will BUG_ON if if the iterator
* has a non-zero offset into the iovec array, but a zero offset is guaranteed for
* these kernels because iov_iter only appeared in 3.16. i am so sorry. */
result = generic_file_direct_write(iocb, BEEGFS_IOV_ITER_RAW(from), &from->nr_segs,
pos,
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
&iocb->ki_pos,
#endif
size, size);
#else
result = generic_file_direct_write(iocb, from, pos);
#endif
......@@ -664,7 +650,7 @@ static ssize_t beegfs_write_iter(struct kiocb* iocb, struct iov_iter* from)
return beegfs_file_write_iter(iocb, from);
}
#if !defined(KERNEL_HAS_WRITE_ITER)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
static ssize_t beegfs_aio_write_iov(struct kiocb* iocb, const struct iovec* iov,
unsigned long nr_segs, loff_t pos)
{
......@@ -676,7 +662,7 @@ static ssize_t beegfs_aio_write_iov(struct kiocb* iocb, const struct iovec* iov,
return beegfs_write_iter(iocb, &iter);
}
#if defined(KERNEL_HAS_AIO_WRITE_BUF)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
static ssize_t beegfs_aio_write(struct kiocb* iocb, const char __user* buf, size_t count,
loff_t pos)
{
......@@ -697,17 +683,17 @@ static ssize_t beegfs_aio_write(struct kiocb* iocb, const struct iovec* iov,
#endif
#ifdef KERNEL_HAS_AIO_WRITE_BUF
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
static ssize_t beegfs_file_read_iter(struct kiocb* iocb, struct iov_iter* from)
{
struct iovec iov = iov_iter_iovec(from);
struct iovec iov = BEEGFS_IOV_ITER_IOVEC(from);
return generic_file_aio_read(iocb, iov.iov_base, iov.iov_len, iocb->ki_pos);
}
#elif !defined(KERNEL_HAS_WRITE_ITER)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
static ssize_t beegfs_file_read_iter(struct kiocb* iocb, struct iov_iter* from)
{
return generic_file_aio_read(iocb, from->iov, from->nr_segs, iocb->ki_pos);
return generic_file_aio_read(iocb, BEEGFS_IOV_ITER_RAW(from), from->nr_segs, iocb->ki_pos);
}
#else
static ssize_t beegfs_file_read_iter(struct kiocb* iocb, struct iov_iter* from)
......@@ -761,7 +747,7 @@ static ssize_t beegfs_read_iter(struct kiocb* iocb, struct iov_iter* to)
return beegfs_file_read_iter(iocb, to);
}
#ifndef KERNEL_HAS_WRITE_ITER
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
static ssize_t beegfs_aio_read_iov(struct kiocb* iocb, const struct iovec* iov,
unsigned long nr_segs, loff_t pos)
{
......@@ -773,7 +759,7 @@ static ssize_t beegfs_aio_read_iov(struct kiocb* iocb, const struct iovec* iov,
return beegfs_read_iter(iocb, &iter);
}
#ifdef KERNEL_HAS_AIO_WRITE_BUF
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
static ssize_t beegfs_aio_read(struct kiocb* iocb, char __user* buf, size_t count,
loff_t pos)
{
......@@ -854,7 +840,7 @@ static int beegfs_fsync(struct file* file, loff_t start, loff_t end, int datasyn
{
return __beegfs_fsync(file, start, end, datasync);
}
#elif defined(KERNEL_HAS_FSYNC_2)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
static int beegfs_fsync(struct file* file, int datasync)
{
return __beegfs_fsync(file, 0, LLONG_MAX, datasync);
......@@ -949,7 +935,7 @@ const struct file_operations fhgfs_file_native_ops = {
.compat_ioctl = FhgfsOpsIoctl_compatIoctl,
#endif
#if !defined(KERNEL_HAS_WRITE_ITER)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)
.read = do_sync_read,
.write = do_sync_write,
.aio_read = beegfs_aio_read,
......@@ -959,7 +945,7 @@ const struct file_operations fhgfs_file_native_ops = {
.write_iter = beegfs_write_iter,
#endif
#if defined(KERNEL_HAS_WRITE_ITER)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)
.splice_read = generic_file_splice_read,
.splice_write = iter_file_splice_write,
#else
......@@ -1918,7 +1904,7 @@ out:
return result;
}
#ifdef KERNEL_HAS_PREPARE_WRITE
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
static int beegfs_prepare_write(struct file* filp, struct page* page, unsigned from, unsigned to)
{
return __beegfs_write_begin(filp, from, to - from + 1, page);
......@@ -2010,7 +1996,7 @@ static void __beegfs_invalidate_page(struct page* page, unsigned begin, unsigned
ard_assign(page, NULL);
}
#if !defined(KERNEL_HAS_INVALIDATEPAGE_RANGE)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
static void beegfs_invalidate_page(struct page* page, unsigned long begin)
{
__beegfs_invalidate_page(page, begin, PAGE_CACHE_SIZE);
......@@ -2173,7 +2159,7 @@ static ssize_t beegfs_direct_IO(int rw, struct kiocb* iocb, const struct iovec*
}
#endif
#if defined(KERNEL_HAS_LAUNDER_PAGE)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
static int beegfs_launderpage(struct page* page)
{
return beegfs_flush_page(page);
......@@ -2191,11 +2177,11 @@ const struct address_space_operations fhgfs_addrspace_native_ops = {
.readpages = beegfs_readpages,
.writepages = beegfs_writepages,
#if defined(KERNEL_HAS_LAUNDER_PAGE)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
.launder_page = beegfs_launderpage,
#endif
#ifdef KERNEL_HAS_PREPARE_WRITE
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
.prepare_write = beegfs_prepare_write,
.commit_write = beegfs_commit_write,
#else
......
......@@ -499,7 +499,7 @@ cleanup:
}
#endif // KERNEL_HAS_POSIX_GET_ACL
#ifdef KERNEL_HAS_SET_ACL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
int FhgfsOps_set_acl(struct inode* inode, struct posix_acl* acl, int type)
{
App* app = FhgfsOps_getApp(inode->i_sb);
......@@ -560,7 +560,7 @@ cleanup:
*/
int FhgfsOps_aclChmod(struct iattr* iattr, struct dentry* dentry)
{
#ifdef KERNEL_HAS_SET_ACL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
if (iattr->ia_valid & ATTR_MODE)
return posix_acl_chmod(dentry->d_inode, iattr->ia_mode);
else
......@@ -1772,7 +1772,7 @@ const char* FhgfsOps_get_link(struct dentry* dentry, struct inode* inode,
return destination;
}
#elif defined(KERNEL_HAS_FOLLOW_LINK_COOKIE)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
const char* FhgfsOps_follow_link(struct dentry* dentry, void** cookie)
{
char* destination;
......@@ -1892,6 +1892,47 @@ int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
return retVal;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
/**
* Note: i_size of the inode is set to the desired size before this is called
*
* Note: unused, can later be removed; truncation is done via sys_truncate -> setattr (and this was
* just called additionally indirectly via sys_truncate -> vmtruncate -> truncate).
*/
void FhgfsOps_truncate(struct inode* inode)
{
App* app = FhgfsOps_getApp(inode->i_sb);
Logger* log = App_getLogger(app);
const char* logContext = "FhgfsOps_truncate";
FhgfsInode* fhgfsInode = BEEGFS_INODE(inode);
loff_t size = i_size_read(inode);
if(unlikely(Logger_getLogLevel(log) >= 5) )
{
struct dentry* dentry = d_find_alias(inode); // calls dget_locked (can return NULL)
FhgfsOpsHelper_logOp(5, app, dentry, inode, logContext);
if(dentry)
dput(dentry);
}
FhgfsInode_entryInfoReadLock(fhgfsInode); // LOCK EntryInfo
// (see below why return val is not checked)
FhgfsOpsRemoting_truncfile(app, FhgfsInode_getEntryInfo(fhgfsInode), size);
FhgfsInode_entryInfoReadUnlock(fhgfsInode); // UNLOCK EntryInfo
return; // note: this is an internal function which gives us no way to return a result.
}
#endif // LINUX_VERSION_CODE
/**
* Note: This is almost a copy of general vmtruncate(), just with inode->i_lock around the i_size
* updates.
......@@ -2100,7 +2141,8 @@ struct inode* __FhgfsOps_newInodeWithParentID(struct super_block* sb, struct kst
inode->i_data.a_ops = &fhgfs_address_ops;
}
#ifdef KERNEL_HAS_ADDRESS_SPACE_BDI
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) ) && \
(LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0) )
inode->i_data.backing_dev_info = FhgfsOps_getBdi(sb);
#endif
......
......@@ -52,7 +52,7 @@ extern struct posix_acl* FhgfsOps_get_acl(struct inode* inode, int type);
int FhgfsOps_aclChmod(struct iattr* iattr, struct dentry* dentry);
#endif // KERNEL_HAS_POSIX_GET_ACL
#ifdef KERNEL_HAS_SET_ACL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
extern int FhgfsOps_set_acl(struct inode* inode, struct posix_acl* acl, int type);
#endif // LINUX_VERSION_CODE
......@@ -90,7 +90,7 @@ extern int FhgfsOps_hardlinkAsSymlink(struct dentry* oldDentry, struct inode* di
#if defined KERNEL_HAS_GET_LINK
extern const char* FhgfsOps_get_link(struct dentry* dentry, struct inode* inode,
struct delayed_call* done);
#elif defined(KERNEL_HAS_FOLLOW_LINK_COOKIE)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
extern const char* FhgfsOps_follow_link(struct dentry* dentry, void** cookie);
extern void FhgfsOps_put_link(struct inode* inode, void* cookie);
#else
......@@ -101,6 +101,10 @@ extern void FhgfsOps_put_link(struct dentry* dentry, struct nameidata* nd, void*
extern int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
struct inode* inodeDirTo, struct dentry* dentryTo);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
extern void FhgfsOps_truncate(struct inode* inode);
#endif // LINUX_VERSION_CODE
extern int FhgfsOps_vmtruncate(struct inode* inode, loff_t offset);
......
......@@ -577,7 +577,7 @@ long FhgfsOpsIoctl_mkfileWithStripeHints(struct file *file, void __user *argp)
.preferredMetaTargets = NULL
};
#ifdef KERNEL_HAS_FILE_F_VFSMNT
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct vfsmount* mnt = file->f_vfsmnt;
#else
struct vfsmount* mnt = file->f_path.mnt;
......@@ -694,7 +694,7 @@ static long FhgfsOpsIoctl_createFile(struct file *file, void __user *argp, bool
int retVal = 0;
FhgfsOpsErr mkRes;
#ifdef KERNEL_HAS_FILE_F_VFSMNT
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct vfsmount* mnt = file->f_vfsmnt;
#else
struct vfsmount* mnt = file->f_path.mnt;
......
......@@ -37,7 +37,7 @@ static struct file_system_type fhgfs_fs_type =
.kill_sb = FhgfsOps_killSB,
//.fs_flags = FS_BINARY_MOUNTDATA, // not required currently
#ifdef KERNEL_HAS_GET_SB_NODEV
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)
.get_sb = FhgfsOps_getSB,
#else
.mount = FhgfsOps_mount, // basically the same thing as get_sb before
......@@ -141,7 +141,7 @@ int __FhgfsOps_constructFsInfo(struct super_block* sb, void* rawMountOptions)
#if defined(KERNEL_HAS_SB_BDI)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
struct backing_dev_info* bdi;
#endif
......@@ -168,7 +168,7 @@ int __FhgfsOps_constructFsInfo(struct super_block* sb, void* rawMountOptions)
log = App_getLogger(app);
IGNORE_UNUSED_VARIABLE(log);
#if defined(KERNEL_HAS_SB_BDI)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
bdi = &sbInfo->bdi;
/* NOTE: The kernel expects a fully initialized bdi structure, so at a minimum it has to be
......@@ -222,7 +222,7 @@ void __FhgfsOps_destructFsInfo(struct super_block* sb)
{
App* app = FhgfsOps_getApp(sb);
#if defined(KERNEL_HAS_SB_BDI)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
struct backing_dev_info* bdi = FhgfsOps_getBdi(sb);
bdi_destroy(bdi);
......@@ -291,7 +291,7 @@ int FhgfsOps_fillSuper(struct super_block* sb, void* rawMountOptions, int silent
sb->s_export_op = &