Re: [PATCH] VFS: make file->f_pos access atomic on 32bit arch

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Hisashi Hifumi
Date: Thursday, September 18, 2008 - 12:08 am

>

I think file_pos_update() with BITS_PER_LONG=32 && CONFIG_PREEMPT is easy,
this is like this.

static inline void file_pos_update(struct file *file, loff_t pos)
{
	preempt_disable();
	if (pos != file->f_pos)
		file->f_pos = pos;
	preempt_enable();
}


But I think BITS_PER_LONG=32 && CONFIG_SMP version has a problem, this is like this.

static inline void file_pos_update(struct file *file, loff_t pos)
{
	write_seqlock(&file->f_pos_seqlock);
	if (pos != file->f_pos)
		file->f_pos = pos;
	write_sequnlock(&file->f_pos_seqlock);
}

file_pos_update acquires seqlock only once, but write_seqlock is called whether file->f_pos
is overwritten or not.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] VFS: make file->f_pos access atomic on 32bit arch, Hisashi Hifumi, (Thu Sep 18, 12:08 am)