Skip to contentSkip to conversation

GFS2: call d_add for a NULL entry when an inode lookup fails

PATCH New Bob Peterson 1 participant 1 message Sep 9, 2014 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: call d_add for a NULL entry when an inode lookup fails

Hi,

This patch was originally written by Benjamin Coddington (credit where credit is due).

GFS2's inode lookup wasn't hashing the dentry when an inode wasn't found. That caused the dentry/inode to get an early cleanup attempt through dentry_kill when a create op cleaned up the filehandle. That caused the entry to hang around until unmount time, which means if the file was created then deleted, its space and inode were not reclaimed until then. This problem was introduced by gfs2's new atomic open code. The patch simply adds the d_add (as other file systems do) when inode lookups fail.

Regards,

Bob Peterson
Red Hat File Systems

---

fs/gfs2/inode.c +3 -1
index e62e594..9317ddc 100644
@@ -840,8 +840,10 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
 	int error;
 
 	inode = gfs2_lookupi(dir, &dentry->d_name, 0);
-	if (!inode)
+	if (inode == NULL) {
+		d_add(dentry, NULL);
 		return NULL;
+	}
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);