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.
--