From mboxrd@z Thu Jan 1 00:00:00 1970 From: Trond Myklebust Subject: Re: [PATCH] Initial support for struct vfs_cred [0/1] Date: Sun, 1 Sep 2002 16:10:01 +0200 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <15730.8121.554630.859558@charged.uio.no> References: <1030822731.1458.127.camel@ldb> <15729.17279.474307.914587@charged.uio.no> <1030835635.1422.39.camel@ldb> <15730.4100.308481.326297@charged.uio.no> Reply-To: trond.myklebust@fys.uio.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Linus Torvalds , Linux FSdevel , Linux Kernel Return-path: To: Luca Barbieri , In-Reply-To: <15730.4100.308481.326297@charged.uio.no> List-Id: linux-fsdevel.vger.kernel.org >>>>> " " == Trond Myklebust writes: >>>>> " " == Luca Barbieri writes: >> For example, rather than this; > >> you can just do this: >> - uid_t saved_fsuid = current->fsuid; >> + uid_t saved_fsuid = current->fscred.uid; >> kernel_cap_t saved_cap = current-> cap_effective; > But I don't want to have to do that at all. Why should I change Just to follow up on why the above 'optimization' is just plain wrong. You are forgetting that the fscred might simultaneously be referenced by an open struct file. Are you saying that this file should suddenly see its credential change? The alternative without copy on write is to make a full copy of the fscred every time we open a file or schedule some form of asynchronous I/O, and hence need to cache the current VFS credentials. The copy-on-write rule is there in order to *minimize* the need to copy the cred. It works because changing the cred's entries is supposed to be a *rare* occurrence, whereas taking references and reading are common. Cheers, Trond