Re: [PATCH 3/3][mmotm] updateing size of kcore

From: AmÃrico Wang
Date: Thu Sep 17 2009 - 02:59:44 EST


On Thu, Sep 17, 2009 at 10:45 AM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
>
> After memory hotplug (or other events in future), kcore size
> can be modified.
>
> To update inode->i_size, we have to know inode/dentry but we
> can't get it from inside /proc directly.
> But considerinyg memory hotplug, kcore image is updated only when
> it's opened. Then, updating inode->i_size at open() is enough.
>
> Cc: WANG Cong <xiyou.wangcong@xxxxxxxxx>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>


This patch looks fine.

However, I am thinking if kcore is the only file under /proc whose size
is changed dynamically? If no, that probably means we need to change
generic proc code.

Thanks!

> ---
> Âfs/proc/kcore.c | Â Â5 +++++
> Â1 file changed, 5 insertions(+)
>
> Index: mmotm-2.6.31-Sep14/fs/proc/kcore.c
> ===================================================================
> --- mmotm-2.6.31-Sep14.orig/fs/proc/kcore.c
> +++ mmotm-2.6.31-Sep14/fs/proc/kcore.c
> @@ -546,6 +546,11 @@ static int open_kcore(struct inode *inod
> Â Â Â Â Â Â Â Âreturn -EPERM;
> Â Â Â Âif (kcore_need_update)
> Â Â Â Â Â Â Â Âkcore_update_ram();
> + Â Â Â if (i_size_read(inode) != proc_root_kcore->size) {
> + Â Â Â Â Â Â Â mutex_lock(&inode->i_mutex);
> + Â Â Â Â Â Â Â i_size_write(inode, proc_root_kcore->size);
> + Â Â Â Â Â Â Â mutex_unlock(&inode->i_mutex);
> + Â Â Â }
> Â Â Â Âreturn 0;
> Â}
>
>
>
--
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/