Skip to content

Commit 3bb7df9

Browse files
author
Miklos Szeredi
committed
ovl: restructure dentry revalidation
Use a common loop for plain and weak revalidation. This will aid doing revalidation on upper layer. This patch doesn't change behavior. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent c61ca55 commit 3bb7df9

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

fs/overlayfs/super.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -113,47 +113,48 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
113113
return dentry;
114114
}
115115

116-
static int ovl_dentry_revalidate(struct dentry *dentry, unsigned int flags)
116+
static int ovl_revalidate_real(struct dentry *d, unsigned int flags, bool weak)
117117
{
118-
struct ovl_entry *oe = dentry->d_fsdata;
119-
unsigned int i;
120118
int ret = 1;
121119

122-
for (i = 0; i < oe->numlower; i++) {
123-
struct dentry *d = oe->lowerstack[i].dentry;
124-
125-
if (d->d_flags & DCACHE_OP_REVALIDATE) {
126-
ret = d->d_op->d_revalidate(d, flags);
127-
if (ret < 0)
128-
return ret;
129-
if (!ret) {
130-
if (!(flags & LOOKUP_RCU))
131-
d_invalidate(d);
132-
return -ESTALE;
133-
}
120+
if (weak) {
121+
if (d->d_flags & DCACHE_OP_WEAK_REVALIDATE)
122+
ret = d->d_op->d_weak_revalidate(d, flags);
123+
} else if (d->d_flags & DCACHE_OP_REVALIDATE) {
124+
ret = d->d_op->d_revalidate(d, flags);
125+
if (!ret) {
126+
if (!(flags & LOOKUP_RCU))
127+
d_invalidate(d);
128+
ret = -ESTALE;
134129
}
135130
}
136-
return 1;
131+
return ret;
137132
}
138133

139-
static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
134+
static int ovl_dentry_revalidate_common(struct dentry *dentry,
135+
unsigned int flags, bool weak)
140136
{
141137
struct ovl_entry *oe = dentry->d_fsdata;
142138
unsigned int i;
143139
int ret = 1;
144140

145-
for (i = 0; i < oe->numlower; i++) {
146-
struct dentry *d = oe->lowerstack[i].dentry;
147-
148-
if (d->d_flags & DCACHE_OP_WEAK_REVALIDATE) {
149-
ret = d->d_op->d_weak_revalidate(d, flags);
150-
if (ret <= 0)
151-
break;
152-
}
141+
for (i = 0; ret > 0 && i < oe->numlower; i++) {
142+
ret = ovl_revalidate_real(oe->lowerstack[i].dentry, flags,
143+
weak);
153144
}
154145
return ret;
155146
}
156147

148+
static int ovl_dentry_revalidate(struct dentry *dentry, unsigned int flags)
149+
{
150+
return ovl_dentry_revalidate_common(dentry, flags, false);
151+
}
152+
153+
static int ovl_dentry_weak_revalidate(struct dentry *dentry, unsigned int flags)
154+
{
155+
return ovl_dentry_revalidate_common(dentry, flags, true);
156+
}
157+
157158
static const struct dentry_operations ovl_dentry_operations = {
158159
.d_release = ovl_dentry_release,
159160
.d_real = ovl_d_real,

0 commit comments

Comments
 (0)