[PATCH] knfsd: reduce stack consumption
A typical nfsd call trace is nfsd -> svc_process -> nfsd_dispatch -> nfsd3_proc_write -> nfsd_write ->nfsd_vfs_write -> vfs_writev These add up to over 300 bytes on the stack. Looking at each of these, I see that nfsd_write (which includes nfsd_vfs_write) contributes 0x8c to stack usage itself!! It turns out this is because it puts a 'struct iattr' on the stack so it can kill suid if needed. The following patch saves about 50 bytes off the stack in this call path. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
a334de2866
commit
9f708e40fe
|
@ -880,6 +880,16 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void kill_suid(struct dentry *dentry)
|
||||||
|
{
|
||||||
|
struct iattr ia;
|
||||||
|
ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID;
|
||||||
|
|
||||||
|
down(&dentry->d_inode->i_sem);
|
||||||
|
notify_change(dentry, &ia);
|
||||||
|
up(&dentry->d_inode->i_sem);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||||
loff_t offset, struct kvec *vec, int vlen,
|
loff_t offset, struct kvec *vec, int vlen,
|
||||||
|
@ -933,14 +943,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear setuid/setgid flag after write */
|
/* clear setuid/setgid flag after write */
|
||||||
if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) {
|
if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
|
||||||
struct iattr ia;
|
kill_suid(dentry);
|
||||||
ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID;
|
|
||||||
|
|
||||||
down(&inode->i_sem);
|
|
||||||
notify_change(dentry, &ia);
|
|
||||||
up(&inode->i_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err >= 0 && stable) {
|
if (err >= 0 && stable) {
|
||||||
static ino_t last_ino;
|
static ino_t last_ino;
|
||||||
|
|
Loading…
Reference in New Issue