Skip to content

Commit

Permalink
RHEL 7.5 compat: FMODE_KABI_ITERATE
Browse files Browse the repository at this point in the history
As of RHEL 7.5 the mainline fops.iterate() method was added to
the file_operations structure.

This wouldn't have been a problem however in order to maintain
KABI compatibility it was added to the very end of the structure.
Callers intending to use this extended interface were additionally
required to set the FMODE_KABI_ITERATE flag on the file struct
when opening the directory.

Update the ZPL to set this RHEL specific flag when required.
Using this interface will mean that kmods built for RHEL 7.5
will not work on 7.4 without being rebuilt.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#7460
  • Loading branch information
behlendorf authored and ofaaland committed Apr 20, 2018
1 parent b0f61cd commit 542c000
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions module/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ zpl_iterate(struct file *filp, struct dir_context *ctx)
return (error);
}

#if defined(HAVE_VFS_ITERATE) && defined(FMODE_KABI_ITERATE)
/*
* RHEL 7.5 compatibility; the fops.iterate() method was added to
* the file_operations structure but in order to maintain KABI
* compatibility all callers must set FMODE_KABI_ITERATE which
* is checked in iterate_dir().
*/
static int
zpl_dir_open(struct inode *ip, struct file *filp)
{
filp->f_mode |= FMODE_KABI_ITERATE;

return (0);
}
#endif

#if !defined(HAVE_VFS_ITERATE) && !defined(HAVE_VFS_ITERATE_SHARED)
static int
zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
Expand Down Expand Up @@ -885,6 +901,9 @@ const struct file_operations zpl_file_operations = {
const struct file_operations zpl_dir_file_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
#if defined(HAVE_VFS_ITERATE) && defined(FMODE_KABI_ITERATE)
.open = zpl_dir_open,
#endif
#ifdef HAVE_VFS_ITERATE_SHARED
.iterate_shared = zpl_iterate,
#elif defined(HAVE_VFS_ITERATE)
Expand Down

0 comments on commit 542c000

Please sign in to comment.