Print this page
patch as-lock-macro-simplification


 517 
 518                         /* check the program text vnode */
 519                         if (prp->p_exec &&
 520                             (VN_CMP(fvp, prp->p_exec) ||
 521                             (contained && (prp->p_exec->v_vfsp == cvfsp))))
 522                                 use_flag |= F_TEXT;
 523                 }
 524 
 525                 /* Now we can drop p_lock again */
 526                 mutex_exit(&prp->p_lock);
 527 
 528                 /*
 529                  * now we want to walk a processes memory mappings.
 530                  * to do this we need to grab the prp->p_as lock.  (you
 531                  * can't hold p_lock when grabbing the prp->p_as lock.)
 532                  */
 533                 if (prp->p_as != &kas) {
 534                         struct seg      *seg;
 535                         struct as       *as = prp->p_as;
 536 
 537                         AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
 538                         for (seg = AS_SEGFIRST(as); seg;
 539                             seg = AS_SEGNEXT(as, seg)) {
 540                                 /*
 541                                  * if we can't get a backing vnode for this
 542                                  * segment then skip it
 543                                  */
 544                                 vp = NULL;
 545                                 if ((SEGOP_GETVP(seg, seg->s_base, &vp)) ||
 546                                     (vp == NULL))
 547                                         continue;
 548 
 549                                 /*
 550                                  * if the target file (fvp) is not a device
 551                                  * and corrosponds to the root of a filesystem
 552                                  * (cvfsp), then check if it contains the
 553                                  * vnode backing this segment (vp).
 554                                  */
 555                                 if (contained && (vp->v_vfsp == cvfsp)) {
 556                                         use_flag |= F_MAP;
 557                                         break;


 581                                  * (vp) maps to the same device minor node
 582                                  * as the target device (fvp)
 583                                  */
 584                                 if (fvp->v_rdev == vp->v_rdev) {
 585                                         use_flag |= F_MAP;
 586                                         break;
 587                                 }
 588 
 589                                 /*
 590                                  * if we're checking for device instance
 591                                  * usage, then check if the vnode backing
 592                                  * this segment (vp) maps to the same device
 593                                  * instance as the target device (fvp).
 594                                  */
 595                                 if (dip_usage &&
 596                                     (VTOCS(fvp)->s_dip == VTOCS(vp)->s_dip)) {
 597                                         use_flag |= F_MAP;
 598                                         break;
 599                                 }
 600                         }
 601                         AS_LOCK_EXIT(as, &as->a_lock);
 602                 }
 603 
 604                 if (use_flag) {
 605                         ASSERT(pcnt < fu_data->fud_user_max);
 606                         fu_data->fud_user[pcnt].fu_flags = use_flag;
 607                         fu_data->fud_user[pcnt].fu_pid = pid;
 608                         fu_data->fud_user[pcnt].fu_uid = uid;
 609                         pcnt++;
 610                 }
 611 
 612                 /*
 613                  * grab the process lock again, clear the SPRLOCK
 614                  * flag, release the process, and continue.
 615                  */
 616                 mutex_enter(&prp->p_lock);
 617                 sprunlock(prp);
 618         }
 619 
 620         kmem_free(pidlist, v_proc * sizeof (pid_t));
 621 




 517 
 518                         /* check the program text vnode */
 519                         if (prp->p_exec &&
 520                             (VN_CMP(fvp, prp->p_exec) ||
 521                             (contained && (prp->p_exec->v_vfsp == cvfsp))))
 522                                 use_flag |= F_TEXT;
 523                 }
 524 
 525                 /* Now we can drop p_lock again */
 526                 mutex_exit(&prp->p_lock);
 527 
 528                 /*
 529                  * now we want to walk a processes memory mappings.
 530                  * to do this we need to grab the prp->p_as lock.  (you
 531                  * can't hold p_lock when grabbing the prp->p_as lock.)
 532                  */
 533                 if (prp->p_as != &kas) {
 534                         struct seg      *seg;
 535                         struct as       *as = prp->p_as;
 536 
 537                         AS_LOCK_ENTER(as, RW_READER);
 538                         for (seg = AS_SEGFIRST(as); seg;
 539                             seg = AS_SEGNEXT(as, seg)) {
 540                                 /*
 541                                  * if we can't get a backing vnode for this
 542                                  * segment then skip it
 543                                  */
 544                                 vp = NULL;
 545                                 if ((SEGOP_GETVP(seg, seg->s_base, &vp)) ||
 546                                     (vp == NULL))
 547                                         continue;
 548 
 549                                 /*
 550                                  * if the target file (fvp) is not a device
 551                                  * and corrosponds to the root of a filesystem
 552                                  * (cvfsp), then check if it contains the
 553                                  * vnode backing this segment (vp).
 554                                  */
 555                                 if (contained && (vp->v_vfsp == cvfsp)) {
 556                                         use_flag |= F_MAP;
 557                                         break;


 581                                  * (vp) maps to the same device minor node
 582                                  * as the target device (fvp)
 583                                  */
 584                                 if (fvp->v_rdev == vp->v_rdev) {
 585                                         use_flag |= F_MAP;
 586                                         break;
 587                                 }
 588 
 589                                 /*
 590                                  * if we're checking for device instance
 591                                  * usage, then check if the vnode backing
 592                                  * this segment (vp) maps to the same device
 593                                  * instance as the target device (fvp).
 594                                  */
 595                                 if (dip_usage &&
 596                                     (VTOCS(fvp)->s_dip == VTOCS(vp)->s_dip)) {
 597                                         use_flag |= F_MAP;
 598                                         break;
 599                                 }
 600                         }
 601                         AS_LOCK_EXIT(as);
 602                 }
 603 
 604                 if (use_flag) {
 605                         ASSERT(pcnt < fu_data->fud_user_max);
 606                         fu_data->fud_user[pcnt].fu_flags = use_flag;
 607                         fu_data->fud_user[pcnt].fu_pid = pid;
 608                         fu_data->fud_user[pcnt].fu_uid = uid;
 609                         pcnt++;
 610                 }
 611 
 612                 /*
 613                  * grab the process lock again, clear the SPRLOCK
 614                  * flag, release the process, and continue.
 615                  */
 616                 mutex_enter(&prp->p_lock);
 617                 sprunlock(prp);
 618         }
 619 
 620         kmem_free(pidlist, v_proc * sizeof (pid_t));
 621