Re: [PATCH 04/23] vfs: Introduce infrastructure for revoking a file

From: Eric W. Biederman
Date: Tue Jun 02 2009 - 02:52:23 EST


Pekka Enberg <penberg@xxxxxxxxxxxxxx> writes:

> Hi Eric,
>
> On Tue, Jun 2, 2009 at 12:50 AM, Eric W. Biederman
> <ebiederm@xxxxxxxxxxxx> wrote:
>> +#ifdef CONFIG_FILE_HOTPLUG
>> +
>> +static bool file_in_use(struct file *file)
>> +{
>> + Â Â Â struct task_struct *leader, *task;
>> + Â Â Â bool in_use = false;
>> + Â Â Â int i;
>> +
>> + Â Â Â rcu_read_lock();
>> + Â Â Â do_each_thread(leader, task) {
>> + Â Â Â Â Â Â Â for (i = 0; i < MAX_FILE_HOTPLUG_LOCK_DEPTH; i++) {
>> + Â Â Â Â Â Â Â Â Â Â Â if (task->file_hotplug_lock[i] == file) {
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â in_use = true;
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto found;
>> + Â Â Â Â Â Â Â Â Â Â Â }
>> + Â Â Â Â Â Â Â }
>> + Â Â Â } while_each_thread(leader, task);
>> +found:
>> + Â Â Â rcu_read_unlock();
>> + Â Â Â return in_use;
>> +}
>
> This seems rather heavy-weight. If we're going to use this
> infrastructure for forced unmount, I think this will be a problem.

> Can't we two this in two stages: (1) mark a bit that forces
> file_hotplug_read_trylock to always fail and (2) block until the last
> remaining in-kernel file_hotplug_read_unlock() has executed?

Yes there is room for more optimization in the slow path.
I haven't noticed being a problem yet so I figured I would start
with stupid and simple.

I can easily see two passes. The first setting the flag an calling
f_op->dead. The second some kind of consolidate walk through the task
list, allowing checking on multiple files at once.

I'm not ready to consider anything that will add cost to the fast
path in the file descriptors though.

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/