Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to proc/file ops to handle kernel 5.6 series #33

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
21 changes: 17 additions & 4 deletions kernel/xpmem_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ xpmem_debug_printk_procfs_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
char buf;

if(copy_from_user(&buf, buffer, 1))
return -EFAULT;

if (buf == '0')
if (buf == '0')
xpmem_debug_on = 0;
else if (buf == '1')
xpmem_debug_on = 1;
Expand All @@ -315,11 +315,24 @@ xpmem_debug_printk_procfs_open(struct inode *inode, struct file *file)
return single_open(file, xpmem_debug_printk_procfs_show, NULL);
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
struct proc_ops xpmem_debug_printk_procfs_ops = {
.proc_lseek = seq_lseek,
.proc_read = seq_read,
.proc_write = xpmem_debug_printk_procfs_write,
.proc_open = xpmem_debug_printk_procfs_open,
.proc_release = single_release,
};
#else
struct file_operations xpmem_debug_printk_procfs_ops = {
struct file_operations xpmem_debug_printk_procfs_ops = {
.owner = THIS_MODULE,
.owner = THIS_MODULE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owner set twice?

.llseek = seq_lseek,
.read = seq_read,
.write = xpmem_debug_printk_procfs_write,
.llseek = seq_lseek,
.open = xpmem_debug_printk_procfs_open,
.open = xpmem_debug_printk_procfs_open,
.release = single_release,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .open member appears to be set twice here.

.release = single_release,
};
#endif /* kernel 5.6 */
17 changes: 15 additions & 2 deletions kernel/xpmem_pfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,24 @@ xpmem_unpin_procfs_open(struct inode *inode, struct file *file)
return single_open(file, xpmem_unpin_procfs_show, PDE_DATA(inode));
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
struct proc_ops xpmem_unpin_procfs_ops = {
.proc_lseek = seq_lseek,
.proc_read = seq_read,
.proc_write = xpmem_unpin_procfs_write,
.proc_open = xpmem_unpin_procfs_open,
.proc_release = single_release,
};
#else
struct file_operations xpmem_unpin_procfs_ops = {
struct file_operations xpmem_unpin_procfs_ops = {
.owner = THIS_MODULE,
.owner = THIS_MODULE,
.llseek = seq_lseek,
.read = seq_read,
.write = xpmem_unpin_procfs_write,
.llseek = seq_lseek,
.open = xpmem_unpin_procfs_open,
.open = xpmem_unpin_procfs_open,
.release = single_release,
.release = single_release,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a merge issue. I don't think this will compile with 5.5.x and older.

#endif /* kernel 5.6 */
8 changes: 8 additions & 0 deletions kernel/xpmem_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ extern int xpmem_fork_end(void);
#define XPMEM_TGID_STRING_LEN 11
extern spinlock_t xpmem_unpin_procfs_lock;
extern struct proc_dir_entry *xpmem_unpin_procfs_dir;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
extern struct proc_ops xpmem_unpin_procfs_ops;
#else
extern struct file_operations xpmem_unpin_procfs_ops;
#endif /* kernel 5.6 */

/* found in xpmem_main.c */
extern struct xpmem_partition *xpmem_my_part;
Expand Down Expand Up @@ -339,7 +343,11 @@ extern int xpmem_seg_down_read(struct xpmem_thread_group *,
struct xpmem_segment *, int, int);
extern int xpmem_validate_access(struct xpmem_access_permit *, off_t, size_t,
int, u64 *);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
extern struct proc_ops xpmem_debug_printk_procfs_ops;
#else
extern struct file_operations xpmem_debug_printk_procfs_ops;
#endif /* kernel 5.6 */
/* found in xpmem_mmu_notifier.c */
extern int xpmem_mmu_notifier_init(struct xpmem_thread_group *);
extern void xpmem_mmu_notifier_unlink(struct xpmem_thread_group *);
Expand Down