aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2012-11-25 14:48:10 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-11-26 09:08:16 -0500
commit063b0fb9fadadc0caaea6c8f31e3f6bc978a4904 (patch)
treed67d23112e25ae14f5c3be1b67db71d8fa45af79 /fs
parentffe1137ba743cdf1c2414d5a89690aec1daa6bba (diff)
nfsd4: downgrade some fs/nfsd/nfs4state.c BUG's
Linus has pointed out that indiscriminate use of BUG's can make it harder to diagnose bugs because they can bring a machine down, often before we manage to get any useful debugging information to the logs. (Consider, for example, a BUG() that fires in a workqueue, or while holding a spinlock). Most of these BUG's won't do much more than kill an nfsd thread, but it would still probably be safer to get out the warning without dying. There's still more of this to do in nfsd/. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4state.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index e75872f81e1c..41d2aed8ed06 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -190,7 +190,7 @@ static struct list_head file_hashtbl[FILE_HASH_SIZE];
190 190
191static void __nfs4_file_get_access(struct nfs4_file *fp, int oflag) 191static void __nfs4_file_get_access(struct nfs4_file *fp, int oflag)
192{ 192{
193 BUG_ON(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR])); 193 WARN_ON_ONCE(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR]));
194 atomic_inc(&fp->fi_access[oflag]); 194 atomic_inc(&fp->fi_access[oflag]);
195} 195}
196 196
@@ -249,7 +249,7 @@ static inline int get_new_stid(struct nfs4_stid *stid)
249 * preallocations that can exist at a time, but the state lock 249 * preallocations that can exist at a time, but the state lock
250 * prevents anyone from using ours before we get here: 250 * prevents anyone from using ours before we get here:
251 */ 251 */
252 BUG_ON(error); 252 WARN_ON_ONCE(error);
253 /* 253 /*
254 * It shouldn't be a problem to reuse an opaque stateid value. 254 * It shouldn't be a problem to reuse an opaque stateid value.
255 * I don't think it is for 4.1. But with 4.0 I worry that, for 255 * I don't think it is for 4.1. But with 4.0 I worry that, for
@@ -494,7 +494,8 @@ static int nfs4_access_to_omode(u32 access)
494 case NFS4_SHARE_ACCESS_BOTH: 494 case NFS4_SHARE_ACCESS_BOTH:
495 return O_RDWR; 495 return O_RDWR;
496 } 496 }
497 BUG(); 497 WARN_ON_ONCE(1);
498 return O_RDONLY;
498} 499}
499 500
500/* release all access and file references for a given stateid */ 501/* release all access and file references for a given stateid */
@@ -1605,10 +1606,9 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
1605 switch (exid->spa_how) { 1606 switch (exid->spa_how) {
1606 case SP4_NONE: 1607 case SP4_NONE:
1607 break; 1608 break;
1609 default: /* checked by xdr code */
1610 WARN_ON_ONCE(1);
1608 case SP4_SSV: 1611 case SP4_SSV:
1609 return nfserr_serverfault;
1610 default:
1611 BUG(); /* checked by xdr code */
1612 case SP4_MACH_CRED: 1612 case SP4_MACH_CRED:
1613 return nfserr_serverfault; /* no excuse :-/ */ 1613 return nfserr_serverfault; /* no excuse :-/ */
1614 } 1614 }
@@ -2912,7 +2912,7 @@ static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status)
2912 open->op_why_no_deleg = WND4_CANCELLED; 2912 open->op_why_no_deleg = WND4_CANCELLED;
2913 break; 2913 break;
2914 case NFS4_SHARE_WANT_NO_DELEG: 2914 case NFS4_SHARE_WANT_NO_DELEG:
2915 BUG(); /* not supposed to get here */ 2915 WARN_ON_ONCE(1);
2916 } 2916 }
2917 } 2917 }
2918} 2918}
@@ -3466,7 +3466,11 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
3466 goto out; 3466 goto out;
3467 if (filpp) { 3467 if (filpp) {
3468 *filpp = dp->dl_file->fi_deleg_file; 3468 *filpp = dp->dl_file->fi_deleg_file;
3469 BUG_ON(!*filpp); 3469 if (!*filpp) {
3470 WARN_ON_ONCE(1);
3471 status = nfserr_serverfault;
3472 goto out;
3473 }
3470 } 3474 }
3471 break; 3475 break;
3472 case NFS4_OPEN_STID: 3476 case NFS4_OPEN_STID:
@@ -3693,7 +3697,7 @@ static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_ac
3693 case NFS4_SHARE_ACCESS_BOTH: 3697 case NFS4_SHARE_ACCESS_BOTH:
3694 break; 3698 break;
3695 default: 3699 default:
3696 BUG(); 3700 WARN_ON_ONCE(1);
3697 } 3701 }
3698} 3702}
3699 3703
@@ -3882,7 +3886,7 @@ last_byte_offset(u64 start, u64 len)
3882{ 3886{
3883 u64 end; 3887 u64 end;
3884 3888
3885 BUG_ON(!len); 3889 WARN_ON_ONCE(!len);
3886 end = start + len; 3890 end = start + len;
3887 return end > start ? end - 1: NFS4_MAX_UINT64; 3891 return end > start ? end - 1: NFS4_MAX_UINT64;
3888} 3892}
@@ -4552,7 +4556,7 @@ nfs4_release_reclaim(struct nfsd_net *nn)
4552 nfs4_remove_reclaim_record(crp, nn); 4556 nfs4_remove_reclaim_record(crp, nn);
4553 } 4557 }
4554 } 4558 }
4555 BUG_ON(nn->reclaim_str_hashtbl_size); 4559 WARN_ON_ONCE(nn->reclaim_str_hashtbl_size);
4556} 4560}
4557 4561
4558/* 4562/*