/* This function synchronizes write-buffers which contain nodes belonging to @inode. Returns zero in case of success and a negative error code in case of failure.  */
int ubifs_sync_wbufs_by_inode(struct ubifs_info *c, struct inode *inode)
/* This function synchronizes write-buffers which contain nodes belonging to @inode. Returns zero in case of success and a negative error code in case of failure.  */
int ubifs_sync_wbufs_by_inode(struct ubifs_info *c, struct inode *inode)
{
	int i, err = 0;
	for (i = 0; i < c->jhead_cnt; i++) {
		struct ubifs_wbuf *wbuf = &c->jheads[i].wbuf;
		if (i == GCHD)
			continue;
		if (!wbuf_has_ino(wbuf, inode->i_ino))
			continue;
		mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead);
		if (wbuf_has_ino(wbuf, inode->i_ino))
			err = ubifs_wbuf_sync_nolock(wbuf);
		mutex_unlock(&wbuf->io_mutex);
		if (err) {
			ubifs_ro_mode(c, err);
			return err;
		}
	}
	return 0;
}