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

fs/9p: We should not allocate a new inode when creating hardlines.

Don't do new_inode_from fid in case of hardlink creation. This ensures
that link count for hardlink files get updated properly. Earlier link count
was not updated on removing a hardlink with cache mode enabled.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

authored by

Aneesh Kumar K.V and committed by
Eric Van Hensbergen
b6054793 df345c67

+24 -19
+24 -19
fs/9p/vfs_inode.c
··· 680 680 goto error; 681 681 } 682 682 683 - /* now walk from the parent so we can get unopened fid */ 684 - fid = p9_client_walk(dfid, 1, &name, 1); 685 - if (IS_ERR(fid)) { 686 - err = PTR_ERR(fid); 687 - p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); 688 - fid = NULL; 689 - goto error; 683 + if (!(perm & P9_DMLINK)) { 684 + /* now walk from the parent so we can get unopened fid */ 685 + fid = p9_client_walk(dfid, 1, &name, 1); 686 + if (IS_ERR(fid)) { 687 + err = PTR_ERR(fid); 688 + p9_debug(P9_DEBUG_VFS, 689 + "p9_client_walk failed %d\n", err); 690 + fid = NULL; 691 + goto error; 692 + } 693 + /* 694 + * instantiate inode and assign the unopened fid to the dentry 695 + */ 696 + inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 697 + if (IS_ERR(inode)) { 698 + err = PTR_ERR(inode); 699 + p9_debug(P9_DEBUG_VFS, 700 + "inode creation failed %d\n", err); 701 + goto error; 702 + } 703 + err = v9fs_fid_add(dentry, fid); 704 + if (err < 0) 705 + goto error; 706 + d_instantiate(dentry, inode); 690 707 } 691 - 692 - /* instantiate inode and assign the unopened fid to the dentry */ 693 - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 694 - if (IS_ERR(inode)) { 695 - err = PTR_ERR(inode); 696 - p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err); 697 - goto error; 698 - } 699 - err = v9fs_fid_add(dentry, fid); 700 - if (err < 0) 701 - goto error; 702 - d_instantiate(dentry, inode); 703 708 return ofid; 704 709 error: 705 710 if (ofid)