Wait_on_bit_lock () using the example

Source: Internet
Author: User
Tags goto
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.