int nfs_writepages (struct address_space *mapping, struct Writeback_control *WBC)
{
struct Inode *inode = mapping->host;
#ifdef use_nfs_congestion
unsigned long *bitlock = &nfs_i (inode)->flags;
#endif
struct Nfs_pageio_descriptor Pgio;
int err;
#ifdef use_nfs_congestion
/* Stop dirtying of new pages while we sync */
err = Wait_on_bit_lock (Bitlock, nfs_ino_flushing,
Nfs_wait_bit_killable, task_killable);
if (ERR)
Goto Out_err;
#endif
Nfs_inc_stats (Inode, nfsios_vfswritepages);
Nfs_pageio_init_write (&pgio, Inode, wb_priority (WBC));
Err = write_cache_pages (mapping, WBC, Nfs_writepages_callback, &pgio);
Nfs_pageio_complete (&pgio);
#ifdef use_nfs_congestion
Clear_bit_unlock (nfs_ino_flushing, Bitlock);
Smp_mb__after_clear_bit ();
Wake_up_bit (Bitlock, nfs_ino_flushing);
#endif
if (Err < 0)
Goto Out_err;
err = Pgio.pg_error;
if (Err < 0)
Goto Out_err;
return 0;
Out_err:
return err;
}
Wait_on_bit_lock () uses atomic bit manipulation, trying to set a bit, if it has been set, then the task is suspended until the call Wake_up_bit () wakes up, waiting for the thread.