source: trunk/server/common/patches/openafs-d_splice_alias-reference.patch @ 2659

Last change on this file since 2659 was 2659, checked in by andersk, 9 years ago
OpenAFS: upgrade to 1.6.11pre1, plus patch for d_alias change
File size: 2.7 KB
  • acinclude.m4

    From b1f23baecb2de72b44cda8bba27615c012a445f1 Mon Sep 17 00:00:00 2001
    From: Marc Dionne <marc.dionne@your-file-system.com>
    Date: Thu, 18 Dec 2014 08:43:22 -0500
    Subject: [PATCH] Linux: d_splice_alias may drop inode reference on error
    
    d_splice_alias now drops the inode reference on error, so we
    need to grab an extra one to make sure that the inode doesn't
    go away, and release it when done if there was no error.
    
    For kernels that may not drop the reference, provide an
    additional iput() within an ifdef.  This could be hooked up
    to a configure option to allow building a module for a kernel
    that is known not to drop the reference on error.  That hook
    is not provided here.  Affected kernels should be the early
    3.17 ones (3.17 - 3.17.2); 3.16 and older kernels should not
    return errors here.
    
    Change-Id: Id1786ac2227b4d8e0ae801fe59c15a0ecd975bed
    ---
     acinclude.m4                 |  3 +++
     src/afs/LINUX/osi_vnodeops.c | 29 ++++++++++++++++++++++++++---
     2 files changed, 29 insertions(+), 3 deletions(-)
    
    diff --git a/acinclude.m4 b/acinclude.m4
    index 96adde0..19f7092 100644
    a b case $AFS_SYSNAME in *_linux* | *_umlinux*) 
    984984                 AC_CHECK_LINUX_FUNC([hlist_unhashed],
    985985                                     [#include <linux/list.h>],
    986986                                     [hlist_unhashed(0);])
     987                 AC_CHECK_LINUX_FUNC([ihold],
     988                                     [#include <linux/fs.h>],
     989                                     [ihold(NULL);])
    987990                 AC_CHECK_LINUX_FUNC([i_size_read],
    988991                                     [#include <linux/fs.h>],
    989992                                     [i_size_read(NULL);])
  • src/afs/LINUX/osi_vnodeops.c

    diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
    index b2ab9d5..cedfef6 100644
    a b afs_linux_lookup(struct inode *dip, struct dentry *dp) 
    16121612        ip->i_flags |= S_AUTOMOUNT;
    16131613#endif
    16141614    }
     1615    /*
     1616     * Take an extra reference so the inode doesn't go away if
     1617     * d_splice_alias drops our reference on error.
     1618     */
     1619    if (ip)
     1620#ifdef HAVE_LINUX_IHOLD
     1621        ihold(ip);
     1622#else
     1623        igrab(ip);
     1624#endif
     1625
    16151626    newdp = d_splice_alias(ip, dp);
    16161627
    16171628 done:
    afs_linux_lookup(struct inode *dip, struct dentry *dp) 
    16251636         * d_splice_alias can return an error (EIO) if there is an existing
    16261637         * connected directory alias for this dentry.
    16271638         */
    1628         if (!IS_ERR(newdp))
     1639        if (!IS_ERR(newdp)) {
     1640            iput(ip);
    16291641            return newdp;
    1630         else {
     1642        } else {
    16311643            d_add(dp, ip);
     1644            /*
     1645             * Depending on the kernel version, d_splice_alias may or may
     1646             * not drop the inode reference on error.  If it didn't, do it
     1647             * here.
     1648             */
     1649#if defined(D_SPLICE_ALIAS_LEAK_ON_ERROR)
     1650            iput(ip);
     1651#endif
    16321652            return NULL;
    16331653        }
    1634     } else
     1654    } else {
     1655        if (ip)
     1656            iput(ip);
    16351657        return ERR_PTR(afs_convert_code(code));
     1658    }
    16361659}
    16371660
    16381661static int
Note: See TracBrowser for help on using the repository browser.