2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 * fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
38 #include <linux/pagemap.h>
39 #include <linux/capability.h>
45 * xfs_iozero clears the specified range of buffer supplied,
46 * and marks all the affected blocks as valid and modified. If
47 * an affected block is not allocated, it will be allocated. If
48 * an affected block is not completely overwritten, and is not
49 * valid before the operation, it will be read from disk before
50 * being partially zeroed.
54 struct inode
*ip
, /* inode */
55 loff_t pos
, /* offset in file */
56 size_t count
, /* size of data to zero */
57 loff_t end_size
) /* max file size to set */
61 struct address_space
*mapping
;
65 mapping
= ip
->i_mapping
;
67 unsigned long index
, offset
;
69 offset
= (pos
& (PAGE_CACHE_SIZE
-1)); /* Within page */
70 index
= pos
>> PAGE_CACHE_SHIFT
;
71 bytes
= PAGE_CACHE_SIZE
- offset
;
76 page
= grab_cache_page(mapping
, index
);
81 status
= mapping
->a_ops
->prepare_write(NULL
, page
, offset
,
87 memset((void *) (kaddr
+ offset
), 0, bytes
);
88 flush_dcache_page(page
);
89 status
= mapping
->a_ops
->commit_write(NULL
, page
, offset
,
95 ip
->i_size
= pos
< end_size
? pos
: end_size
;
101 page_cache_release(page
);
109 ssize_t
/* bytes read, or (-) error */
113 const struct iovec
*iovp
,
125 int direct
= filp
->f_flags
& O_DIRECT
;
127 ip
= XFS_BHVTOI(bdp
);
128 vp
= BHV_TO_VNODE(bdp
);
130 vn_trace_entry(vp
, "xfs_read", (inst_t
*)__return_address
);
132 XFS_STATS_INC(xfsstats
.xs_read_calls
);
134 /* START copy & waste from filemap.c */
135 for (seg
= 0; seg
< segs
; seg
++) {
136 const struct iovec
*iv
= &iovp
[seg
];
139 * If any segment has a negative length, or the cumulative
140 * length ever wraps negative then return -EINVAL.
143 if (unlikely((ssize_t
)(size
|iv
->iov_len
) < 0))
144 return XFS_ERROR(-EINVAL
);
145 if (direct
) { /* XFS specific check */
146 if ((__psint_t
)iv
->iov_base
& BBMASK
) {
147 if (*offp
== ip
->i_d
.di_size
)
149 return XFS_ERROR(-EINVAL
);
152 if (access_ok(VERIFY_WRITE
, iv
->iov_base
, iv
->iov_len
))
155 return XFS_ERROR(-EFAULT
);
159 /* END copy & waste from filemap.c */
162 if ((*offp
& mp
->m_blockmask
) ||
163 (size
& mp
->m_blockmask
)) {
164 if (*offp
== ip
->i_d
.di_size
) {
167 return -XFS_ERROR(EINVAL
);
171 n
= XFS_MAX_FILE_OFFSET
- *offp
;
172 if ((n
<= 0) || (size
== 0))
178 if (XFS_FORCED_SHUTDOWN(mp
)) {
182 xfs_ilock(ip
, XFS_IOLOCK_SHARED
);
184 if (DM_EVENT_ENABLED(vp
->v_vfsp
, ip
, DM_EVENT_READ
) &&
185 !(filp
->f_mode
& FINVIS
)) {
187 vrwlock_t locktype
= VRWLOCK_READ
;
189 error
= xfs_dm_send_data_event(DM_EVENT_READ
, bdp
, *offp
,
190 size
, FILP_DELAY_FLAG(filp
), &locktype
);
192 xfs_iunlock(ip
, XFS_IOLOCK_SHARED
);
197 ret
= generic_file_readv(filp
, iovp
, segs
, offp
);
198 xfs_iunlock(ip
, XFS_IOLOCK_SHARED
);
200 XFS_STATS_ADD(xfsstats
.xs_read_bytes
, ret
);
202 if (!(filp
->f_mode
& FINVIS
))
203 xfs_ichgtime(ip
, XFS_ICHGTIME_ACC
);
222 int invisible
= (filp
->f_mode
& FINVIS
);
224 ip
= XFS_BHVTOI(bdp
);
225 vp
= BHV_TO_VNODE(bdp
);
226 vn_trace_entry(vp
, "xfs_sendfile", (inst_t
*)__return_address
);
228 XFS_STATS_INC(xfsstats
.xs_read_calls
);
230 n
= XFS_MAX_FILE_OFFSET
- *offp
;
231 if ((n
<= 0) || (count
== 0))
237 if (XFS_FORCED_SHUTDOWN(ip
->i_mount
))
240 xfs_ilock(ip
, XFS_IOLOCK_SHARED
);
241 if (DM_EVENT_ENABLED(vp
->v_vfsp
, ip
, DM_EVENT_READ
) && !invisible
) {
242 vrwlock_t locktype
= VRWLOCK_READ
;
245 error
= xfs_dm_send_data_event(DM_EVENT_READ
, bdp
, *offp
,
246 count
, FILP_DELAY_FLAG(filp
), &locktype
);
248 xfs_iunlock(ip
, XFS_IOLOCK_SHARED
);
252 ret
= generic_file_sendfile(filp
, offp
, count
, actor
, target
);
253 xfs_iunlock(ip
, XFS_IOLOCK_SHARED
);
255 XFS_STATS_ADD(xfsstats
.xs_read_bytes
, ret
);
257 xfs_ichgtime(ip
, XFS_ICHGTIME_ACC
);
262 * This routine is called to handle zeroing any space in the last
263 * block of the file that is beyond the EOF. We do this since the
264 * size is being increased without writing anything to that block
265 * and we don't want anyone to read the garbage on the disk.
267 STATIC
int /* error (positive) */
273 xfs_fsize_t end_size
)
275 xfs_fileoff_t last_fsb
;
280 int isize_fsb_offset
;
282 xfs_bmbt_irec_t imap
;
286 ASSERT(ismrlocked(io
->io_lock
, MR_UPDATE
) != 0);
287 ASSERT(offset
> isize
);
291 isize_fsb_offset
= XFS_B_FSB_OFFSET(mp
, isize
);
292 if (isize_fsb_offset
== 0) {
294 * There are no extra bytes in the last block on disk to
300 last_fsb
= XFS_B_TO_FSBT(mp
, isize
);
302 error
= XFS_BMAPI(mp
, NULL
, io
, last_fsb
, 1, 0, NULL
, 0, &imap
,
309 * If the block underlying isize is just a hole, then there
310 * is nothing to zero.
312 if (imap
.br_startblock
== HOLESTARTBLOCK
) {
316 * Zero the part of the last block beyond the EOF, and write it
317 * out sync. We need to drop the ilock while we do this so we
318 * don't deadlock when the buffer cache calls back to us.
320 XFS_IUNLOCK(mp
, io
, XFS_ILOCK_EXCL
| XFS_EXTSIZE_RD
);
321 loff
= XFS_FSB_TO_B(mp
, last_fsb
);
322 lsize
= XFS_FSB_TO_B(mp
, 1);
324 zero_offset
= isize_fsb_offset
;
325 zero_len
= mp
->m_sb
.sb_blocksize
- isize_fsb_offset
;
327 error
= xfs_iozero(ip
, loff
+ zero_offset
, zero_len
, end_size
);
329 XFS_ILOCK(mp
, io
, XFS_ILOCK_EXCL
|XFS_EXTSIZE_RD
);
335 * Zero any on disk space between the current EOF and the new,
336 * larger EOF. This handles the normal case of zeroing the remainder
337 * of the last block in the file and the unusual case of zeroing blocks
338 * out beyond the size of the file. This second case only happens
339 * with fixed size extents and when the system crashes before the inode
340 * size was updated but after blocks were allocated. If fill is set,
341 * then any holes in the range are filled and zeroed. If not, the holes
342 * are left alone as holes.
345 int /* error (positive) */
349 xfs_off_t offset
, /* starting I/O offset */
350 xfs_fsize_t isize
, /* current inode size */
351 xfs_fsize_t end_size
) /* terminal inode size */
353 struct inode
*ip
= LINVFS_GET_IP(vp
);
354 xfs_fileoff_t start_zero_fsb
;
355 xfs_fileoff_t end_zero_fsb
;
356 xfs_fileoff_t prev_zero_fsb
;
357 xfs_fileoff_t zero_count_fsb
;
358 xfs_fileoff_t last_fsb
;
359 xfs_extlen_t buf_len_fsb
;
360 xfs_extlen_t prev_zero_count
;
364 xfs_bmbt_irec_t imap
;
368 ASSERT(ismrlocked(io
->io_lock
, MR_UPDATE
));
369 ASSERT(ismrlocked(io
->io_iolock
, MR_UPDATE
));
374 * First handle zeroing the block on which isize resides.
375 * We only zero a part of that block so it is handled specially.
377 error
= xfs_zero_last_block(ip
, io
, offset
, isize
, end_size
);
379 ASSERT(ismrlocked(io
->io_lock
, MR_UPDATE
));
380 ASSERT(ismrlocked(io
->io_iolock
, MR_UPDATE
));
385 * Calculate the range between the new size and the old
386 * where blocks needing to be zeroed may exist. To get the
387 * block where the last byte in the file currently resides,
388 * we need to subtract one from the size and truncate back
389 * to a block boundary. We subtract 1 in case the size is
390 * exactly on a block boundary.
392 last_fsb
= isize
? XFS_B_TO_FSBT(mp
, isize
- 1) : (xfs_fileoff_t
)-1;
393 start_zero_fsb
= XFS_B_TO_FSB(mp
, (xfs_ufsize_t
)isize
);
394 end_zero_fsb
= XFS_B_TO_FSBT(mp
, offset
- 1);
395 ASSERT((xfs_sfiloff_t
)last_fsb
< (xfs_sfiloff_t
)start_zero_fsb
);
396 if (last_fsb
== end_zero_fsb
) {
398 * The size was only incremented on its last block.
399 * We took care of that above, so just return.
404 ASSERT(start_zero_fsb
<= end_zero_fsb
);
405 prev_zero_fsb
= NULLFILEOFF
;
407 while (start_zero_fsb
<= end_zero_fsb
) {
409 zero_count_fsb
= end_zero_fsb
- start_zero_fsb
+ 1;
410 error
= XFS_BMAPI(mp
, NULL
, io
, start_zero_fsb
, zero_count_fsb
,
411 0, NULL
, 0, &imap
, &nimaps
, NULL
);
413 ASSERT(ismrlocked(io
->io_lock
, MR_UPDATE
));
414 ASSERT(ismrlocked(io
->io_iolock
, MR_UPDATE
));
419 if (imap
.br_startblock
== HOLESTARTBLOCK
) {
421 * This loop handles initializing pages that were
422 * partially initialized by the code below this
423 * loop. It basically zeroes the part of the page
424 * that sits on a hole and sets the page as P_HOLE
425 * and calls remapf if it is a mapped file.
427 prev_zero_fsb
= NULLFILEOFF
;
429 start_zero_fsb
= imap
.br_startoff
+
431 ASSERT(start_zero_fsb
<= (end_zero_fsb
+ 1));
436 * There are blocks in the range requested.
437 * Zero them a single write at a time. We actually
438 * don't zero the entire range returned if it is
439 * too big and simply loop around to get the rest.
440 * That is not the most efficient thing to do, but it
441 * is simple and this path should not be exercised often.
443 buf_len_fsb
= XFS_FILBLKS_MIN(imap
.br_blockcount
,
444 mp
->m_writeio_blocks
<< 8);
446 * Drop the inode lock while we're doing the I/O.
447 * We'll still have the iolock to protect us.
449 XFS_IUNLOCK(mp
, io
, XFS_ILOCK_EXCL
|XFS_EXTSIZE_RD
);
451 loff
= XFS_FSB_TO_B(mp
, start_zero_fsb
);
452 lsize
= XFS_FSB_TO_B(mp
, buf_len_fsb
);
454 error
= xfs_iozero(ip
, loff
, lsize
, end_size
);
460 prev_zero_fsb
= start_zero_fsb
;
461 prev_zero_count
= buf_len_fsb
;
462 start_zero_fsb
= imap
.br_startoff
+ buf_len_fsb
;
463 ASSERT(start_zero_fsb
<= (end_zero_fsb
+ 1));
465 XFS_ILOCK(mp
, io
, XFS_ILOCK_EXCL
|XFS_EXTSIZE_RD
);
472 XFS_ILOCK(mp
, io
, XFS_ILOCK_EXCL
|XFS_EXTSIZE_RD
);
477 ssize_t
/* bytes written, or (-) error */
481 const struct iovec
*iovp
,
491 xfs_fsize_t isize
, new_size
;
492 xfs_fsize_t n
, limit
= XFS_MAX_FILE_OFFSET
;
497 int direct
= file
->f_flags
& O_DIRECT
;
501 XFS_STATS_INC(xfsstats
.xs_write_calls
);
503 vp
= BHV_TO_VNODE(bdp
);
504 vn_trace_entry(vp
, "xfs_write", (inst_t
*)__return_address
);
505 xip
= XFS_BHVTOI(bdp
);
507 /* START copy & waste from filemap.c */
508 for (seg
= 0; seg
< segs
; seg
++) {
509 const struct iovec
*iv
= &iovp
[seg
];
512 * If any segment has a negative length, or the cumulative
513 * length ever wraps negative then return -EINVAL.
516 if (unlikely((ssize_t
)(size
|iv
->iov_len
) < 0))
517 return XFS_ERROR(-EINVAL
);
518 if (direct
) { /* XFS specific check */
519 if ((__psint_t
)iv
->iov_base
& BBMASK
)
520 return XFS_ERROR(-EINVAL
);
522 if (access_ok(VERIFY_READ
, iv
->iov_base
, iv
->iov_len
))
525 return XFS_ERROR(-EFAULT
);
529 /* END copy & waste from filemap.c */
534 io
= &(xip
->i_iocore
);
537 xfs_check_frozen(mp
, bdp
, XFS_FREEZE_WRITE
);
539 if (XFS_FORCED_SHUTDOWN(xip
->i_mount
)) {
544 if ((*offset
& mp
->m_blockmask
) ||
545 (size
& mp
->m_blockmask
)) {
546 return XFS_ERROR(-EINVAL
);
548 iolock
= XFS_IOLOCK_SHARED
;
549 locktype
= VRWLOCK_WRITE_DIRECT
;
551 iolock
= XFS_IOLOCK_EXCL
;
552 locktype
= VRWLOCK_WRITE
;
555 xfs_ilock(xip
, XFS_ILOCK_EXCL
|iolock
);
556 isize
= xip
->i_d
.di_size
;
558 if (file
->f_flags
& O_APPEND
)
564 xfs_iunlock(xip
, XFS_ILOCK_EXCL
|iolock
);
571 new_size
= *offset
+ size
;
572 if (new_size
> isize
) {
573 io
->io_new_size
= new_size
;
576 if ((DM_EVENT_ENABLED(vp
->v_vfsp
, xip
, DM_EVENT_WRITE
) &&
577 !(file
->f_mode
& FINVIS
) && !eventsent
)) {
578 loff_t savedsize
= *offset
;
580 xfs_iunlock(xip
, XFS_ILOCK_EXCL
);
581 error
= xfs_dm_send_data_event(DM_EVENT_WRITE
, bdp
,
583 FILP_DELAY_FLAG(file
), &locktype
);
585 xfs_iunlock(xip
, iolock
);
588 xfs_ilock(xip
, XFS_ILOCK_EXCL
);
592 * The iolock was dropped and reaquired in
593 * xfs_dm_send_data_event so we have to recheck the size
594 * when appending. We will only "goto start;" once,
595 * since having sent the event prevents another call
596 * to xfs_dm_send_data_event, which is what
597 * allows the size to change in the first place.
599 if ((file
->f_flags
& O_APPEND
) &&
600 savedsize
!= xip
->i_d
.di_size
) {
601 *offset
= isize
= xip
->i_d
.di_size
;
607 * On Linux, generic_file_write updates the times even if
608 * no data is copied in so long as the write had a size.
610 * We must update xfs' times since revalidate will overcopy xfs.
613 if (!(file
->f_mode
& FINVIS
))
614 xfs_ichgtime(xip
, XFS_ICHGTIME_MOD
| XFS_ICHGTIME_CHG
);
618 * If the offset is beyond the size of the file, we have a couple
619 * of things to do. First, if there is already space allocated
620 * we need to either create holes or zero the disk or ...
622 * If there is a page where the previous size lands, we need
623 * to zero it out up to the new size.
626 if (!direct
&& (*offset
> isize
&& isize
)) {
627 error
= xfs_zero_eof(BHV_TO_VNODE(bdp
), io
, *offset
,
628 isize
, *offset
+ size
);
630 xfs_iunlock(xip
, XFS_ILOCK_EXCL
|iolock
);
634 xfs_iunlock(xip
, XFS_ILOCK_EXCL
);
637 * If we're writing the file then make sure to clear the
638 * setuid and setgid bits if the process is not being run
639 * by root. This keeps people from modifying setuid and
643 if (((xip
->i_d
.di_mode
& ISUID
) ||
644 ((xip
->i_d
.di_mode
& (ISGID
| (IEXEC
>> 3))) ==
645 (ISGID
| (IEXEC
>> 3)))) &&
646 !capable(CAP_FSETID
)) {
647 error
= xfs_write_clear_setuid(xip
);
649 xfs_iunlock(xip
, iolock
);
656 xfs_inval_cached_pages(vp
, &xip
->i_iocore
, *offset
, 1, 1);
659 ret
= generic_file_write_nolock(file
, iovp
, segs
, offset
);
661 if ((ret
== -ENOSPC
) &&
662 DM_EVENT_ENABLED(vp
->v_vfsp
, xip
, DM_EVENT_NOSPACE
) &&
663 !(file
->f_mode
& FINVIS
)) {
665 xfs_rwunlock(bdp
, locktype
);
666 error
= dm_send_namesp_event(DM_EVENT_NOSPACE
, bdp
,
667 DM_RIGHT_NULL
, bdp
, DM_RIGHT_NULL
, NULL
, NULL
,
668 0, 0, 0); /* Delay flag intentionally unused */
671 xfs_rwlock(bdp
, locktype
);
672 *offset
= xip
->i_d
.di_size
;
678 xfs_rwunlock(bdp
, locktype
);
682 XFS_STATS_ADD(xfsstats
.xs_write_bytes
, ret
);
684 if (*offset
> xip
->i_d
.di_size
) {
685 xfs_ilock(xip
, XFS_ILOCK_EXCL
);
686 if (*offset
> xip
->i_d
.di_size
) {
687 struct inode
*inode
= LINVFS_GET_IP(vp
);
689 inode
->i_size
= xip
->i_d
.di_size
= *offset
;
690 xip
->i_update_core
= 1;
691 xip
->i_update_size
= 1;
693 xfs_iunlock(xip
, XFS_ILOCK_EXCL
);
696 /* Handle various SYNC-type writes */
697 if ((file
->f_flags
& O_SYNC
) || IS_SYNC(file
->f_dentry
->d_inode
)) {
700 * If we're treating this as O_DSYNC and we have not updated the
701 * size, force the log.
704 if (!(mp
->m_flags
& XFS_MOUNT_OSYNCISOSYNC
)
705 && !(xip
->i_update_size
)) {
707 * If an allocation transaction occurred
708 * without extending the size, then we have to force
709 * the log up the proper point to ensure that the
710 * allocation is permanent. We can't count on
711 * the fact that buffered writes lock out direct I/O
712 * writes - the direct I/O write could have extended
713 * the size nontransactionally, then finished before
714 * we started. xfs_write_file will think that the file
715 * didn't grow but the update isn't safe unless the
716 * size change is logged.
718 * Force the log if we've committed a transaction
719 * against the inode or if someone else has and
720 * the commit record hasn't gone to disk (e.g.
721 * the inode is pinned). This guarantees that
722 * all changes affecting the inode are permanent
726 xfs_inode_log_item_t
*iip
;
730 if (iip
&& iip
->ili_last_lsn
) {
731 lsn
= iip
->ili_last_lsn
;
732 xfs_log_force(mp
, lsn
,
733 XFS_LOG_FORCE
| XFS_LOG_SYNC
);
734 } else if (xfs_ipincount(xip
) > 0) {
735 xfs_log_force(mp
, (xfs_lsn_t
)0,
736 XFS_LOG_FORCE
| XFS_LOG_SYNC
);
743 * O_SYNC or O_DSYNC _with_ a size update are handled
746 * If the write was synchronous then we need to make
747 * sure that the inode modification time is permanent.
748 * We'll have updated the timestamp above, so here
749 * we use a synchronous transaction to log the inode.
750 * It's not fast, but it's necessary.
752 * If this a dsync write and the size got changed
753 * non-transactionally, then we need to ensure that
754 * the size change gets logged in a synchronous
758 tp
= xfs_trans_alloc(mp
, XFS_TRANS_WRITE_SYNC
);
759 if ((error
= xfs_trans_reserve(tp
, 0,
760 XFS_SWRITE_LOG_RES(mp
),
762 /* Transaction reserve failed */
763 xfs_trans_cancel(tp
, 0);
765 /* Transaction reserve successful */
766 xfs_ilock(xip
, XFS_ILOCK_EXCL
);
767 xfs_trans_ijoin(tp
, xip
, XFS_ILOCK_EXCL
);
768 xfs_trans_ihold(tp
, xip
);
769 xfs_trans_log_inode(tp
, xip
, XFS_ILOG_CORE
);
770 xfs_trans_set_sync(tp
);
771 error
= xfs_trans_commit(tp
, 0, (xfs_lsn_t
)0);
772 xfs_iunlock(xip
, XFS_ILOCK_EXCL
);
775 } /* (ioflags & O_SYNC) */
777 xfs_rwunlock(bdp
, locktype
);
782 * All xfs metadata buffers except log state machine buffers
783 * get this attached as their b_bdstrat callback function.
784 * This is so that we can catch a buffer
785 * after prematurely unpinning it to forcibly shutdown the filesystem.
788 xfs_bdstrat_cb(struct xfs_buf
*bp
)
792 mp
= XFS_BUF_FSPRIVATE3(bp
, xfs_mount_t
*);
793 if (!XFS_FORCED_SHUTDOWN(mp
)) {
794 pagebuf_iorequest(bp
);
797 xfs_buftrace("XFS__BDSTRAT IOERROR", bp
);
799 * Metadata write that didn't get logged but
800 * written delayed anyway. These aren't associated
801 * with a transaction, and can be ignored.
803 if (XFS_BUF_IODONE_FUNC(bp
) == NULL
&&
804 (XFS_BUF_ISREAD(bp
)) == 0)
805 return (xfs_bioerror_relse(bp
));
807 return (xfs_bioerror(bp
));
813 xfs_bmap(bhv_desc_t
*bdp
,
817 page_buf_bmap_t
*pbmapp
,
820 xfs_inode_t
*ip
= XFS_BHVTOI(bdp
);
821 xfs_iocore_t
*io
= &ip
->i_iocore
;
823 ASSERT((ip
->i_d
.di_mode
& IFMT
) == IFREG
);
824 ASSERT(((ip
->i_d
.di_flags
& XFS_DIFLAG_REALTIME
) != 0) ==
825 ((ip
->i_iocore
.io_flags
& XFS_IOCORE_RT
) != 0));
827 return xfs_iomap(io
, offset
, count
, flags
, pbmapp
, npbmaps
);
831 * Wrapper around bdstrat so that we can stop data
832 * from going to disk in case we are shutting down the filesystem.
833 * Typically user data goes thru this path; one of the exceptions
838 struct xfs_mount
*mp
,
842 if (!XFS_FORCED_SHUTDOWN(mp
)) {
843 /* Grio redirection would go here
844 * if (XFS_BUF_IS_GRIO(bp)) {
847 pagebuf_iorequest(bp
);
851 xfs_buftrace("XFSBDSTRAT IOERROR", bp
);
852 return (xfs_bioerror_relse(bp
));
857 XFS_bflush(xfs_buftarg_t
*target
)
859 pagebuf_delwri_flush(target
, PBDF_WAIT
, NULL
);
863 /* Push all fs state out to disk
867 XFS_log_write_unmount_ro(bhv_desc_t
*bdp
)
874 mp
= XFS_BHVTOM(bdp
);
875 pagebuf_delwri_flush(mp
->m_ddev_targp
, PBDF_WAIT
, &pincount
);
876 xfs_finish_reclaim_all(mp
);
879 VFS_SYNC(XFS_MTOVFS(mp
), SYNC_ATTR
|SYNC_WAIT
, NULL
, error
);
880 pagebuf_delwri_flush(mp
->m_ddev_targp
, PBDF_WAIT
, &pincount
);
881 if (pincount
== 0) {delay(50); count
++;}
884 /* Ok now write out an unmount record */
885 xfs_log_unmount_write(mp
);
886 xfs_unmountfs_writesb(mp
);
890 * If the underlying (log or data) device is readonly, there are some
891 * operations that cannot proceed.
894 xfs_dev_is_read_only(xfs_mount_t
*mp
, char *message
)
896 if (bdev_read_only(mp
->m_ddev_targp
->pbr_bdev
) ||
897 bdev_read_only(mp
->m_logdev_targp
->pbr_bdev
) ||
898 (mp
->m_rtdev_targp
&& bdev_read_only(mp
->m_rtdev_targp
->pbr_bdev
))) {
900 "XFS: %s required on read-only device.", message
);
902 "XFS: write access unavailable, cannot proceed.");