568 struct file *file = iocb->ki_filp;
569 struct address_space *mapping = file->f_mapping;
570 struct inode *inode = mapping->host;
571 unsigned long segs = nsegs;
572 xfs_mount_t *mp;
573 ssize_t ret = 0, error = 0;
574 xfs_fsize_t isize, new_size;
575 int iolock;
576 int eventsent = 0;
577 size_t ocount = 0, count;
578 loff_t pos;
579 int need_i_mutex;
580
581 XFS_STATS_INC(xs_write_calls);
582
583 error = generic_segment_checks(iovp, &segs, &ocount, VERIFY_READ);
584 if (error)
585 return error;
586
587 count = ocount;
588 pos = *offset;
589
590 if (count == 0)
591 return 0;
592
593 mp = xip->i_mount;
594
595 xfs_wait_for_freeze(mp, SB_FREEZE_WRITE);
596
597 if (XFS_FORCED_SHUTDOWN(mp))
598 return -EIO;
599
600relock:
601 if (ioflags & IO_ISDIRECT) {
602 iolock = XFS_IOLOCK_SHARED;
603 need_i_mutex = 0;
604 } else {
605 iolock = XFS_IOLOCK_EXCL;
606 need_i_mutex = 1;
607 mutex_lock(&inode->i_mutex);
608 }